This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SQLObject development repository".
The branch, master has been updated
discards eaa996cb589e2d740dadd94c2c10a0e91d2811fe (commit)
discards 9ef9f2e420cdfd623002f9327c9510a4933ab06b (commit)
via afcbff10a92d1364562313b51a9cb417064cae9b (commit)
via 2f477e94e751126c9e661406f74aa8dc14e8a6fc (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (eaa996cb589e2d740dadd94c2c10a0e91d2811fe)
\
N -- N -- N (afcbff10a92d1364562313b51a9cb417064cae9b)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceforge.net/p/sqlobject/sqlobject/ci/afcbff10a92d1364562313b51a9cb417064cae9b
commit afcbff10a92d1364562313b51a9cb417064cae9b
Author: Oleg Broytman <ph...@ph...>
Date: Fri Nov 18 00:39:46 2016 +0300
Add support for mysql-connector
diff --git a/.travis.yml b/.travis.yml
index bf2d010..1e314c2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,6 +19,10 @@ env:
- TOXENV=py27-mysqldb
- TOXENV=py34-mysqlclient
- TOXENV=py35-mysqlclient
+ - TOXENV=py26-mysql-connector
+ - TOXENV=py27-mysql-connector
+ - TOXENV=py34-mysql-connector
+ - TOXENV=py35-mysql-connector
- TOXENV=py26-postgres
- TOXENV=py27-postgres
- TOXENV=py34-postgres
@@ -36,6 +40,10 @@ install: pip install tox coveralls codecov
matrix:
allow_failures:
+ - env: TOXENV=py26-mysql-connector
+ - env: TOXENV=py27-mysql-connector
+ - env: TOXENV=py34-mysql-connector
+ - env: TOXENV=py35-mysql-connector
- env: TOXENV=py26-oursql
- env: TOXENV=py27-oursql
fast_finish: true
diff --git a/docs/News.rst b/docs/News.rst
index 1353f2c..1ca10c2 100644
--- a/docs/News.rst
+++ b/docs/News.rst
@@ -13,30 +13,38 @@ SQLObject 3.2.0 (master)
Minor features
--------------
-* Drop table name from ``VACUUM`` command in SQLiteConnection:
- SQLite doesn't vacuum a single table and SQLite 3.15 uses the supplied name
- as the name of the attached database to vacuum.
+* Drop table name from ``VACUUM`` command in SQLiteConnection: SQLite
+ doesn't vacuum a single table and SQLite 3.15 uses the supplied name as
+ the name of the attached database to vacuum.
* Remove ``driver`` keyword from RdbhostConnection as it allows one driver
``rdbhdb``.
-* Add ``driver`` keyword for FirebirdConnection. Allowed values are 'fdb' or
- 'kinterbasdb'. Default is to test 'fdb' and 'kinterbasdb' in that order.
+* Add ``driver`` keyword for FirebirdConnection. Allowed values are 'fdb'
+ or 'kinterbasdb'. Default is to test 'fdb' and 'kinterbasdb' in that
+ order.
+
+* Add support for `MySQL Connector
+ <https://pypi.python.org/pypi/mysql-connector>`_ (pure python; `binary
+ packages <https://dev.mysql.com/doc/connector-python/en/>`_ are not at
+ PyPI and hence are hard to install and test; most tests are passed, but
+ there are still problems).
* Add support for `oursql <https://github.com/python-oursql/oursql>`_ MySQL
driver (Python 2.6 and 2.7; most tests are passed, but there are still
problems).
-* Add ``driver`` keyword for MySQLConnection. Allowed values are 'mysqldb' and
- 'oursql'. Default is to test for mysqldb only (oursql still causes problems).
+* Add ``driver`` keyword for MySQLConnection. Allowed value are 'mysqldb',
+ 'connector' and 'oursql'. Default is to test for mysqldb only;
+ (connector and oursql drivers still cause problems).
Documentation
-------------
* The docs are now generated with Sphinx.
-* Move ``docs/LICENSE`` to the top-level directory so that Github recognizes
- it.
+* Move ``docs/LICENSE`` to the top-level directory so that Github
+ recognizes it.
Tests
-----
@@ -46,8 +54,8 @@ Tests
* Great Renaming: fix ``pytest`` warnings by renaming ``TestXXX`` classes
to ``SOTestXXX`` to prevent ``pytest`` to recognize them as test classes.
-* Fix ``pytest`` warnings by converting yield tests to plain calls:
- yield tests were deprecated in ``pytest``.
+* Fix ``pytest`` warnings by converting yield tests to plain calls: yield
+ tests were deprecated in ``pytest``.
* Tests are now run at CIs with ``python3.5``.
diff --git a/docs/SQLObject.rst b/docs/SQLObject.rst
index 074d0ad..8680097 100644
--- a/docs/SQLObject.rst
+++ b/docs/SQLObject.rst
@@ -47,14 +47,16 @@ Requirements
============
Currently SQLObject supports MySQL_ via MySQLdb_ aka MySQL-python (called
-mysqlclient_ for Python 3) or oursql_, PostgreSQL_ via psycopg2_ or
-psycopg1, SQLite_ via PySQLite_, Firebird_ via fdb_ or kinterbasdb_, `MAX
-DB`_ (also known as SAP DB) via sapdb_, Sybase via Sybase_, and `MSSQL
-Server`_ via pymssql_ (+ FreeTDS_) or adodbapi_ (Win32).
+mysqlclient_ for Python 3) or `MySQL Connector`_ or oursql_, PostgreSQL_
+via psycopg2_ or psycopg1, SQLite_ via PySQLite_, Firebird_ via fdb_ or
+kinterbasdb_, `MAX DB`_ (also known as SAP DB) via sapdb_, Sybase via
+Sybase_, and `MSSQL Server`_ via pymssql_ (+ FreeTDS_) or adodbapi_
+(Win32).
.. _MySQL: https://www.mysql.com/
.. _MySQLdb: https://sourceforge.net/projects/mysql-python/
.. _mysqlclient: https://pypi.python.org/pypi/mysqlclient
+.. _`MySQL Connector`: https://pypi.python.org/pypi/mysql-connector
.. _oursql: https://github.com/python-oursql/oursql
.. _PostgreSQL: https://postgresql.org
.. _psycopg2: http://initd.org/psycopg/
diff --git a/docs/TODO.rst b/docs/TODO.rst
index f8038cd..7c78877 100644
--- a/docs/TODO.rst
+++ b/docs/TODO.rst
@@ -68,8 +68,6 @@ TODO
* Switch from setuptools to distribute.
-* MySQL Connector/Python: https://dev.mysql.com/doc/connector-python/en/
-
* Pure Python Mysql Interface: https://github.com/nasi/MyPy
* Ultramysql `for Python2 <https://github.com/esnme/ultramysql>`_ and
diff --git a/sqlobject/col.py b/sqlobject/col.py
index 0a3f783..7eb5a82 100644
--- a/sqlobject/col.py
+++ b/sqlobject/col.py
@@ -599,8 +599,15 @@ class StringValidator(SOValidator):
return value
if hasattr(value, '__unicode__'):
return unicode(value).encode(dbEncoding)
- if dbName == 'mysql' and not PY2 and isinstance(value, bytes):
- return value.decode('ascii', errors='surrogateescape')
+ if dbName == 'mysql':
+ if isinstance(value, bytearray):
+ if PY2:
+ value = value.decode(dbEncoding)
+ return value.encode(dbEncoding) # convrt to bytes
+ else:
+ return value.decode(dbEncoding, errors='surrogateescape')
+ if not PY2 and isinstance(value, bytes):
+ return value.decode('ascii', errors='surrogateescape')
raise validators.Invalid(
"expected a str in the StringCol '%s', got %s %r instead" % (
self.name, type(value), value), value, state)
diff --git a/sqlobject/mysql/mysqlconnection.py b/sqlobject/mysql/mysqlconnection.py
index ecfeb4d..729886a 100644
--- a/sqlobject/mysql/mysqlconnection.py
+++ b/sqlobject/mysql/mysqlconnection.py
@@ -39,6 +39,14 @@ class MySQLConnection(DBAPI):
MySQLdb.constants.CR.SERVER_GONE_ERROR
self.CR_SERVER_LOST = MySQLdb.constants.CR.SERVER_LOST
self.ER_DUP_ENTRY = MySQLdb.constants.ER.DUP_ENTRY
+ elif driver == 'connector':
+ import mysql.connector
+ self.module = mysql.connector
+ self.CR_SERVER_GONE_ERROR = \
+ mysql.connector.errorcode.CR_SERVER_GONE_ERROR
+ self.CR_SERVER_LOST = \
+ mysql.connector.errorcode.CR_SERVER_LOST
+ self.ER_DUP_ENTRY = mysql.connector.errorcode.ER_DUP_ENTRY
elif driver == 'oursql':
import oursql
self.module = oursql
@@ -49,7 +57,7 @@ class MySQLConnection(DBAPI):
else:
raise ValueError(
'Unknown MySQL driver "%s", '
- 'expected mysqldb or oursql' % driver)
+ 'expected mysqldb, connector or oursql' % driver)
except ImportError:
pass
else:
@@ -58,7 +66,7 @@ class MySQLConnection(DBAPI):
raise ImportError(
'Cannot find a MySQL driver, tried %s' % drivers)
self.host = host
- self.port = port
+ self.port = port or 3306
self.db = db
self.user = user
self.password = password
@@ -95,7 +103,7 @@ class MySQLConnection(DBAPI):
def _connectionFromParams(cls, user, password, host, port, path, args):
return cls(db=path.strip('/'),
user=user or '', password=password or '',
- host=host or 'localhost', port=port or 0, **args)
+ host=host or 'localhost', port=port, **args)
def makeConnection(self):
dbEncoding = self.dbEncoding
@@ -107,21 +115,21 @@ class MySQLConnection(DBAPI):
def character_set_name(self):
return dbEncoding + '_' + dbEncoding
Connection.character_set_name = character_set_name
+ if self.module.__name__ == 'mysql.connector':
+ self.kw['consume_results'] = True
try:
conn = self.module.connect(
host=self.host, port=self.port, db=self.db,
user=self.user, passwd=self.password, **self.kw)
- if self.module.__name__ == 'MySQLdb':
- # Attempt to reconnect. This setting is persistent.
- conn.ping(True)
+ # Attempt to reconnect. This setting is persistent.
+ conn.ping(True)
except self.module.OperationalError as e:
conninfo = ("; used connection string: "
"host=%(host)s, port=%(port)s, "
"db=%(db)s, user=%(user)s" % self.__dict__)
raise dberrors.OperationalError(ErrorMessage(e, conninfo))
- if hasattr(conn, 'autocommit'):
- conn.autocommit(bool(self.autoCommit))
+ self._setAutoCommit(conn, bool(self.autoCommit))
if dbEncoding and self.module.__name__ == 'MySQLdb':
if hasattr(conn, 'set_character_set'): # MySQLdb 1.2.1 and later
@@ -134,7 +142,11 @@ class MySQLConnection(DBAPI):
def _setAutoCommit(self, conn, auto):
if hasattr(conn, 'autocommit'):
- conn.autocommit(auto)
+ try:
+ conn.autocommit(auto)
+ except TypeError:
+ # mysql-connector has autocommit as a property
+ conn.autocommit = auto
def _executeRetry(self, conn, cursor, query):
# When a server connection is lost and a query is attempted, most of
diff --git a/tox.ini b/tox.ini
index 65b3fd5..4d97831 100644
--- a/tox.ini
+++ b/tox.ini
@@ -61,6 +61,24 @@ commands = {[oursql]commands}
[testenv:py27-oursql]
commands = {[oursql]commands}
+[mysql-connector]
+commands =
+ mysql -e 'create database sqlobject_test;'
+ pytest --cov=sqlobject -D mysql://root:@localhost/sqlobject_test?driver=connector&charset=utf8
+ mysql -e 'drop database sqlobject_test;'
+
+[testenv:py26-mysql-connector]
+commands = {[mysql-connector]commands}
+
+[testenv:py27-mysql-connector]
+commands = {[mysql-connector]commands}
+
+[testenv:py34-mysql-connector]
+commands = {[mysql-connector]commands}
+
+[testenv:py35-mysql-connector]
+commands = {[mysql-connector]commands}
+
# PostgreSQL test environments
[postgresql]
commands =
http://sourceforge.net/p/sqlobject/sqlobject/ci/2f477e94e751126c9e661406f74aa8dc14e8a6fc
commit 2f477e94e751126c9e661406f74aa8dc14e8a6fc
Author: Oleg Broytman <ph...@ph...>
Date: Wed Nov 16 23:11:16 2016 +0300
Add support for oursql MySQL driver
diff --git a/.travis.yml b/.travis.yml
index fc8002b..bf2d010 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,24 +15,29 @@ addons:
postgresql: "9.4"
env:
- - TOXENV=py26-mysql
+ - TOXENV=py26-mysqldb
+ - TOXENV=py27-mysqldb
+ - TOXENV=py34-mysqlclient
+ - TOXENV=py35-mysqlclient
- TOXENV=py26-postgres
- - TOXENV=py26-sqlite
- - TOXENV=py27-mysql
- TOXENV=py27-postgres
- - TOXENV=py27-sqlite
- - TOXENV=py34-mysqlclient
- TOXENV=py34-postgres
- - TOXENV=py34-sqlite
- - TOXENV=py35-mysqlclient
- TOXENV=py35-postgres
+ - TOXENV=py26-sqlite
+ - TOXENV=py27-sqlite
+ - TOXENV=py34-sqlite
- TOXENV=py35-sqlite
+ - TOXENV=py26-oursql
+ - TOXENV=py27-oursql
- TOXENV=py27-flake8
- TOXENV=py34-flake8
install: pip install tox coveralls codecov
matrix:
+ allow_failures:
+ - env: TOXENV=py26-oursql
+ - env: TOXENV=py27-oursql
fast_finish: true
script: tox -e ${TOXENV}
diff --git a/circle.yml b/circle.yml
index 9e7c927..f3b9ff0 100644
--- a/circle.yml
+++ b/circle.yml
@@ -12,5 +12,5 @@ dependencies:
test:
override:
- - case $CIRCLE_NODE_INDEX in 0) tox -e '{py26,py27}-mysql,{py34,py35}-mysqlclient' ;; 1) tox -e '{py26,py27,py34,py35}-postgres' ;; 2) tox -e '{py26,py27,py34,py35}-sqlite' ;; 3) tox -e '{py27,py34}-flake8' ;; esac:
+ - case $CIRCLE_NODE_INDEX in 0) tox -e '{py26,py27}-mysqldb,{py34,py35}-mysqlclient' ;; 1) tox -e '{py26,py27,py34,py35}-postgres' ;; 2) tox -e '{py26,py27,py34,py35}-sqlite' ;; 3) tox -e '{py27,py34}-flake8' ;; esac:
parallel: true
diff --git a/docs/News.rst b/docs/News.rst
index 35c5e46..1353f2c 100644
--- a/docs/News.rst
+++ b/docs/News.rst
@@ -23,7 +23,12 @@ Minor features
* Add ``driver`` keyword for FirebirdConnection. Allowed values are 'fdb' or
'kinterbasdb'. Default is to test 'fdb' and 'kinterbasdb' in that order.
-* Add ``driver`` keyword for MySQLConnection. Allowed value is 'mysqldb'.
+* Add support for `oursql <https://github.com/python-oursql/oursql>`_ MySQL
+ driver (Python 2.6 and 2.7; most tests are passed, but there are still
+ problems).
+
+* Add ``driver`` keyword for MySQLConnection. Allowed values are 'mysqldb' and
+ 'oursql'. Default is to test for mysqldb only (oursql still causes problems).
Documentation
-------------
diff --git a/docs/SQLObject.rst b/docs/SQLObject.rst
index d207a0a..074d0ad 100644
--- a/docs/SQLObject.rst
+++ b/docs/SQLObject.rst
@@ -46,14 +46,16 @@ used with the same query syntax.
Requirements
============
-Currently SQLObject supports MySQL_ via MySQLdb_ aka MySQL-python,
-PostgreSQL_ via psycopg2_ or psycopg1, SQLite_ via PySQLite_, Firebird_
-via fdb_ or kinterbasdb_, `MAX DB`_ (also known as SAP DB) via sapdb_,
-Sybase via Sybase_, and `MSSQL Server`_ via pymssql_ (+ FreeTDS_) or
-adodbapi_ (Win32).
+Currently SQLObject supports MySQL_ via MySQLdb_ aka MySQL-python (called
+mysqlclient_ for Python 3) or oursql_, PostgreSQL_ via psycopg2_ or
+psycopg1, SQLite_ via PySQLite_, Firebird_ via fdb_ or kinterbasdb_, `MAX
+DB`_ (also known as SAP DB) via sapdb_, Sybase via Sybase_, and `MSSQL
+Server`_ via pymssql_ (+ FreeTDS_) or adodbapi_ (Win32).
.. _MySQL: https://www.mysql.com/
.. _MySQLdb: https://sourceforge.net/projects/mysql-python/
+.. _mysqlclient: https://pypi.python.org/pypi/mysqlclient
+.. _oursql: https://github.com/python-oursql/oursql
.. _PostgreSQL: https://postgresql.org
.. _psycopg2: http://initd.org/psycopg/
.. _SQLite: https://sqlite.org/
diff --git a/docs/TODO.rst b/docs/TODO.rst
index ba8c7d4..f8038cd 100644
--- a/docs/TODO.rst
+++ b/docs/TODO.rst
@@ -68,8 +68,6 @@ TODO
* Switch from setuptools to distribute.
-* oursql MySQL bindings: https://github.com/python-oursql/oursql
-
* MySQL Connector/Python: https://dev.mysql.com/doc/connector-python/en/
* Pure Python Mysql Interface: https://github.com/nasi/MyPy
diff --git a/sqlobject/col.py b/sqlobject/col.py
index e405127..0a3f783 100644
--- a/sqlobject/col.py
+++ b/sqlobject/col.py
@@ -1879,6 +1879,8 @@ class UuidValidator(SOValidator):
def to_python(self, value, state):
if value is None:
return None
+ if PY2 and isinstance(value, unicode):
+ value = value.encode('ascii')
if isinstance(value, str):
return UUID(value)
raise validators.Invalid(
diff --git a/sqlobject/mysql/mysqlconnection.py b/sqlobject/mysql/mysqlconnection.py
index df26f20..ecfeb4d 100644
--- a/sqlobject/mysql/mysqlconnection.py
+++ b/sqlobject/mysql/mysqlconnection.py
@@ -39,10 +39,17 @@ class MySQLConnection(DBAPI):
MySQLdb.constants.CR.SERVER_GONE_ERROR
self.CR_SERVER_LOST = MySQLdb.constants.CR.SERVER_LOST
self.ER_DUP_ENTRY = MySQLdb.constants.ER.DUP_ENTRY
+ elif driver == 'oursql':
+ import oursql
+ self.module = oursql
+ self.CR_SERVER_GONE_ERROR = \
+ oursql.errnos['CR_SERVER_GONE_ERROR']
+ self.CR_SERVER_LOST = oursql.errnos['CR_SERVER_LOST']
+ self.ER_DUP_ENTRY = oursql.errnos['ER_DUP_ENTRY']
else:
raise ValueError(
'Unknown MySQL driver "%s", '
- 'expected mysqldb' % driver)
+ 'expected mysqldb or oursql' % driver)
except ImportError:
pass
else:
@@ -163,7 +170,8 @@ class MySQLConnection(DBAPI):
except self.module.InternalError as e:
raise dberrors.InternalError(ErrorMessage(e))
except self.module.ProgrammingError as e:
- raise dberrors.ProgrammingError(ErrorMessage(e))
+ if e.args[0] is not None:
+ raise dberrors.ProgrammingError(ErrorMessage(e))
except self.module.DataError as e:
raise dberrors.DataError(ErrorMessage(e))
except self.module.NotSupportedError as e:
diff --git a/sqlobject/tests/test_validation.py b/sqlobject/tests/test_validation.py
index ef61178..86f1a10 100644
--- a/sqlobject/tests/test_validation.py
+++ b/sqlobject/tests/test_validation.py
@@ -34,7 +34,7 @@ class SOValidation(SQLObject):
name = StringCol(validator=validators.PlainText(),
default='x', dbName='name_col')
- name2 = StringCol(validator=validators.ConfirmType(type=str), default='y')
+ name2 = StringCol(validator2=validators.ConfirmType(type=str), default='y')
name3 = IntCol(validator=validators.Wrapper(fromPython=int), default=100)
name4 = FloatCol(default=2.718)
name5 = PickleCol(default=None)
diff --git a/tox.ini b/tox.ini
index e6f632f..65b3fd5 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
[tox]
minversion = 1.8
-envlist = {py26,py27}-mysql,{py26,py27,py34,py35}-postgres,{py26,py27,py34,py35}-sqlite,{py34,py35}-mysqlclient,{py27,py34}-flake8
+envlist = {py26,py27}-{mysqldb,oursql},{py34,py35}-mysqlclient,{py26,py27,py34,py35}-{postgres,sqlite},{py27,py34}-flake8
# Base test environment settings
[testenv]
@@ -13,8 +13,9 @@ deps =
py34,py35: FormEncode >= 1.3.1
PyDispatcher>=2.0.4
py26,py27: egenix-mx-base
- mysql: mysql-python
+ mysqldb: mysql-python
mysqlclient: mysqlclient
+ py26,py27: oursql
postgres: psycopg2
passenv = CI TRAVIS TRAVIS_*
# Don't fail or warn on uninstalled commands
@@ -24,17 +25,41 @@ whitelist_externals =
dropdb
# MySQL test environments
-[mysql]
... 70 lines suppressed ...
hooks/post-receive
--
SQLObject development repository
|