Skip to content

Release/0.7 #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changes

## 0.7

Release date: 2016-01-10

Notable changes:

* Faster binary escaping
* Add `"_binary" prefix` to string literal for binary types.
binary types are: `bytearray` on Python 2, `bytes` and `bytearray` on Python 3.
This is because recent MySQL show warnings when string literal is invalid for
connection encoding.
* `pymysql.Binary()` returns `bytearray` on Python 2. This is required to distinguish
binary and string.
* Auth plugin support.
* no_delay option is ignored. It will be removed in PyMySQL 0.8.


## 0.6.7

Release date: 2015-09-30
Expand Down
36 changes: 16 additions & 20 deletions pymysql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
"""
PyMySQL: A pure-Python MySQL client library.

Copyright (c) 2010, 2013 PyMySQL contributors
Copyright (c) 2010-2016 PyMySQL contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,12 +20,10 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import sys

'''

VERSION = (0, 6, 7, None)

from ._compat import text_type, JYTHON, IRONPYTHON, PY2
from ._compat import PY2
from .constants import FIELD_TYPE
from .converters import escape_dict, escape_sequence, escape_string
from .err import Warning, Error, InterfaceError, DataError, \
Expand All @@ -34,15 +32,14 @@
from .times import Date, Time, Timestamp, \
DateFromTicks, TimeFromTicks, TimestampFromTicks

import sys


VERSION = (0, 7, 0, None)
threadsafety = 1
apilevel = "2.0"
paramstyle = "format"
paramstyle = "pyformat"

class DBAPISet(frozenset):

class DBAPISet(frozenset):

def __ne__(self, other):
if isinstance(other, set):
Expand Down Expand Up @@ -73,15 +70,15 @@ def __hash__(self):
DATETIME = TIMESTAMP
ROWID = DBAPISet()


def Binary(x):
"""Return x as a binary type."""
if isinstance(x, text_type) and not (JYTHON or IRONPYTHON):
x = x.encode()
if PY2:
return bytearray(x)
else:
return bytes(x)


def Connect(*args, **kwargs):
"""
Connect to the database; see connections.Connection.__init__() for
Expand All @@ -92,11 +89,10 @@ def Connect(*args, **kwargs):

from pymysql import connections as _orig_conn
if _orig_conn.Connection.__init__.__doc__ is not None:
Connect.__doc__ = _orig_conn.Connection.__init__.__doc__ + ("""
See connections.Connection.__init__() for information about defaults.
""")
Connect.__doc__ = _orig_conn.Connection.__init__.__doc__
del _orig_conn


def get_client_info(): # for MySQLdb compatibility
return '.'.join(map(str, VERSION))

Expand All @@ -110,7 +106,7 @@ def get_client_info(): # for MySQLdb compatibility
__version__ = get_client_info()

def thread_safe():
return True # match MySQLdb.thread_safe()
return True # match MySQLdb.thread_safe()

def install_as_MySQLdb():
"""
Expand All @@ -119,6 +115,7 @@ def install_as_MySQLdb():
"""
sys.modules["MySQLdb"] = sys.modules["_mysql"] = sys.modules["pymysql"]


__all__ = [
'BINARY', 'Binary', 'Connect', 'Connection', 'DATE', 'Date',
'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks', 'TimestampFromTicks',
Expand All @@ -131,6 +128,5 @@ def install_as_MySQLdb():
'paramstyle', 'threadsafety', 'version_info',

"install_as_MySQLdb",

"NULL","__version__",
]
"NULL", "__version__",
]
1 change: 0 additions & 1 deletion pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ class Connection(object):

The proper way to get an instance of this class is to call
connect().

"""

socket = None
Expand Down
4 changes: 2 additions & 2 deletions pymysql/tests/test_connection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import datetime
import decimal
import sys
import time
import unittest2
import pymysql
from pymysql.tests import base
from pymysql._compat import text_type


class TempUser:
Expand Down Expand Up @@ -534,7 +534,7 @@ def test_escape_fallback_encoder(self):
class Custom(str):
pass

mapping = {pymysql.text_type: pymysql.escape_string}
mapping = {text_type: pymysql.escape_string}
self.assertEqual(con.escape(Custom('foobar'), mapping), "'foobar'")

def test_escape_no_default(self):
Expand Down
3 changes: 2 additions & 1 deletion pymysql/tests/thirdparty/test_MySQLdb/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def setUp(self):
self.BLOBUText = unicode().join(unichr(i) for i in range(16834))
else:
self.BLOBUText = "".join(chr(i) for i in range(16834))
self.BLOBBinary = self.db_module.Binary(''.join([chr(i) for i in range(256)] * 16))
data = bytearray(range(256)) * 16
self.BLOBBinary = self.db_module.Binary(data)

leak_test = True

Expand Down
4 changes: 2 additions & 2 deletions pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,8 @@ def test_Timestamp(self):
# self.assertEqual(str(t1),str(t2))

def test_Binary(self):
b = self.driver.Binary('Something')
b = self.driver.Binary('')
b = self.driver.Binary(b'Something')
b = self.driver.Binary(b'')

def test_STRING(self):
self.assertTrue(hasattr(self.driver,'STRING'),
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ universal = 1
[flake8]
ignore = E226,E301,E701
exclude = tests,build
max-line-length = 99
max-line-length = 119
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
author_email='yutaka.matsubara@gmail.com',
maintainer='INADA Naoki',
maintainer_email='songofacandy@gmail.com',
description='Pure-Python MySQL Driver',
description='Pure Python MySQL Driver',
license="MIT",
packages=find_packages(),
classifiers=[
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
Expand All @@ -33,5 +32,5 @@
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Topic :: Database',
]
],
)