Author: phd
Date: 2007-12-14 06:26:40 -0700 (Fri, 14 Dec 2007)
New Revision: 3174
Modified:
SQLObject/branches/0.8/docs/News.txt
SQLObject/branches/0.8/sqlobject/mysql/mysqlconnection.py
Log:
MySQLConnection doesn't convert query strings to unicode (but allows to
pass unicode query strings if the user build ones). DB URI parameter
sqlobject_encoding is no longer used.
Modified: SQLObject/branches/0.8/docs/News.txt
===================================================================
--- SQLObject/branches/0.8/docs/News.txt 2007-12-14 13:26:07 UTC (rev 3173)
+++ SQLObject/branches/0.8/docs/News.txt 2007-12-14 13:26:40 UTC (rev 3174)
@@ -200,6 +200,10 @@
* With PySQLite2 do not use encode()/decode() from PySQLite1 - always use
base64 for BLOBs.
+* MySQLConnection doesn't convert query strings to unicode (but allows to
+ pass unicode query strings if the user build ones). DB URI parameter
+ sqlobject_encoding is no longer used.
+
SQLObject 0.7.9
===============
Modified: SQLObject/branches/0.8/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/mysql/mysqlconnection.py 2007-12-14 13:26:07 UTC (rev 3173)
+++ SQLObject/branches/0.8/sqlobject/mysql/mysqlconnection.py 2007-12-14 13:26:40 UTC (rev 3174)
@@ -1,6 +1,7 @@
+from sqlobject import col
from sqlobject.dbconnection import DBAPI
from sqlobject.dberrors import *
-from sqlobject import col
+from sqlobject.main import deprecated
MySQLdb = None
class ErrorMessage(str):
@@ -28,10 +29,6 @@
self.user = user
self.password = password
self.kw = {}
- if MySQLdb.version_info[:3] >= (1, 2, 1):
- self.need_unicode = True
- else:
- self.need_unicode = False
for key in ("unix_socket", "init_command",
"read_default_file", "read_default_group"):
if key in kw:
@@ -45,9 +42,8 @@
else:
self.dbEncoding = None
if "sqlobject_encoding" in kw:
- self.encoding = col.popKey(kw, "sqlobject_encoding")
- else:
- self.encoding = 'ascii'
+ del kw["sqlobject_encoding"]
+ deprecated("sqlobject_encoding is deprecated and no longer used.")
DBAPI.__init__(self, **kw)
def connectionFromURI(cls, uri):
@@ -79,12 +75,12 @@
if hasattr(conn, 'autocommit'):
conn.autocommit(bool(self.autoCommit))
- if self.dbEncoding:
+ if dbEncoding:
if hasattr(conn, 'set_character_set'): # MySQLdb 1.2.1 and later
- conn.set_character_set(self.dbEncoding)
+ conn.set_character_set(dbEncoding)
else: # pre MySQLdb 1.2.1
# works along with monkeypatching code above
- conn.query("SET NAMES %s" % self.dbEncoding)
+ conn.query("SET NAMES %s" % dbEncoding)
return conn
@@ -107,13 +103,6 @@
# done by calling ping(True) on the connection.
for count in range(3):
try:
- # For MySQLdb 1.2.1 and later, we go
- # encoding->unicode->charset (in the mysql db)
- if self.need_unicode and not isinstance(query, unicode):
- try:
- query = unicode(query, self.encoding)
- except UnicodeError:
- pass
return cursor.execute(query)
except MySQLdb.OperationalError, e:
if e.args[0] in (MySQLdb.constants.CR.SERVER_GONE_ERROR, MySQLdb.constants.CR.SERVER_LOST):
@@ -225,10 +214,10 @@
if self.dbEncoding: kw['dbEncoding'] = self.dbEncoding
kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
kw['dbName'] = field
-
+
# Since MySQL 5.0, 'NO' is returned in the NULL column (SQLObject expected '')
kw['notNone'] = (nullAllowed.upper() != 'YES' and True or False)
-
+
if default and t.startswith('int'):
kw['default'] = int(default)
elif default and t.startswith('float'):
|