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
via a038cb0153ffa2ed2c95d9d70db255ca8919dfe6 (commit)
via a631ca22d539e106f92f087cfafdeeb39203c735 (commit)
from e1d4f413811961e75bcfb924fdaf4dd92e074847 (commit)
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/a038cb0153ffa2ed2c95d9d70db255ca8919dfe6
commit a038cb0153ffa2ed2c95d9d70db255ca8919dfe6
Author: Oleg Broytman <ph...@ph...>
Date: Thu Nov 17 00:47:17 2016 +0300
oursql MySQL driver: tried but failed
[skip ci]
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
http://sourceforge.net/p/sqlobject/sqlobject/ci/a631ca22d539e106f92f087cfafdeeb39203c735
commit a631ca22d539e106f92f087cfafdeeb39203c735
Author: Oleg Broytman <ph...@ph...>
Date: Thu Nov 17 00:46:16 2016 +0300
Prepare MySQLConnection to use different drivers
diff --git a/sqlobject/mysql/mysqlconnection.py b/sqlobject/mysql/mysqlconnection.py
index 3372ef1..df26f20 100644
--- a/sqlobject/mysql/mysqlconnection.py
+++ b/sqlobject/mysql/mysqlconnection.py
@@ -29,9 +29,16 @@ class MySQLConnection(DBAPI):
try:
if driver.lower() == 'mysqldb':
import MySQLdb
+ if MySQLdb.version_info[:3] < (1, 2, 2):
+ raise ValueError(
+ 'SQLObject requires MySQLdb 1.2.2 or later')
import MySQLdb.constants.CR
import MySQLdb.constants.ER
self.module = MySQLdb
+ self.CR_SERVER_GONE_ERROR = \
+ MySQLdb.constants.CR.SERVER_GONE_ERROR
+ self.CR_SERVER_LOST = MySQLdb.constants.CR.SERVER_LOST
+ self.ER_DUP_ENTRY = MySQLdb.constants.ER.DUP_ENTRY
else:
raise ValueError(
'Unknown MySQL driver "%s", '
@@ -69,13 +76,10 @@ class MySQLConnection(DBAPI):
global mysql_Bin
if not PY2 and mysql_Bin is None:
- mysql_Bin = MySQLdb.Binary
- MySQLdb.Binary = lambda x: mysql_Bin(x).decode(
+ mysql_Bin = self.module.Binary
+ self.module.Binary = lambda x: mysql_Bin(x).decode(
'ascii', errors='surrogateescape')
- if self.module.version_info[:3] < (1, 2, 2):
- raise ValueError('SQLObject requires MySQLdb 1.2.2 or later')
-
self._server_version = None
self._can_use_microseconds = None
DBAPI.__init__(self, **kw)
@@ -89,17 +93,18 @@ class MySQLConnection(DBAPI):
def makeConnection(self):
dbEncoding = self.dbEncoding
if dbEncoding:
- from MySQLdb.connections import Connection
- if not hasattr(Connection, 'set_character_set'):
- # monkeypatch pre MySQLdb 1.2.1
- def character_set_name(self):
- return dbEncoding + '_' + dbEncoding
- Connection.character_set_name = character_set_name
+ if self.module.__name__ == 'MySQLdb':
+ from MySQLdb.connections import Connection
+ if not hasattr(Connection, 'set_character_set'):
+ # monkeypatch pre MySQLdb 1.2.1
+ def character_set_name(self):
+ return dbEncoding + '_' + dbEncoding
+ Connection.character_set_name = character_set_name
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.version_info[:3] >= (1, 2, 2):
+ if self.module.__name__ == 'MySQLdb':
# Attempt to reconnect. This setting is persistent.
conn.ping(True)
except self.module.OperationalError as e:
@@ -111,7 +116,7 @@ class MySQLConnection(DBAPI):
if hasattr(conn, 'autocommit'):
conn.autocommit(bool(self.autoCommit))
- if dbEncoding:
+ if dbEncoding and self.module.__name__ == 'MySQLdb':
if hasattr(conn, 'set_character_set'): # MySQLdb 1.2.1 and later
conn.set_character_set(dbEncoding)
else: # pre MySQLdb 1.2.1
@@ -141,8 +146,8 @@ class MySQLConnection(DBAPI):
try:
return cursor.execute(query)
except self.module.OperationalError as e:
- if e.args[0] in (self.module.constants.CR.SERVER_GONE_ERROR,
- self.module.constants.CR.SERVER_LOST):
+ if e.args[0] in (self.CR_SERVER_GONE_ERROR,
+ self.CR_SERVER_LOST):
if count == 2:
raise dberrors.OperationalError(ErrorMessage(e))
if self.debug:
@@ -151,7 +156,7 @@ class MySQLConnection(DBAPI):
raise dberrors.OperationalError(ErrorMessage(e))
except self.module.IntegrityError as e:
msg = ErrorMessage(e)
- if e.args[0] == self.module.constants.ER.DUP_ENTRY:
+ if e.args[0] == self.ER_DUP_ENTRY:
raise dberrors.DuplicateEntryError(msg)
else:
raise dberrors.IntegrityError(msg)
-----------------------------------------------------------------------
Summary of changes:
docs/TODO.rst | 2 -
sqlobject/mysql/mysqlconnection.py | 37 ++++++++++++++++++++---------------
2 files changed, 21 insertions(+), 18 deletions(-)
hooks/post-receive
--
SQLObject development repository
|