[SQL-CVS] r3176 - in SQLObject/trunk: docs sqlobject/mysql
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2007-12-14 13:27:13
|
Author: phd
Date: 2007-12-14 06:27:08 -0700 (Fri, 14 Dec 2007)
New Revision: 3176
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/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/trunk/docs/News.txt
===================================================================
--- SQLObject/trunk/docs/News.txt 2007-12-14 13:26:54 UTC (rev 3175)
+++ SQLObject/trunk/docs/News.txt 2007-12-14 13:27:08 UTC (rev 3176)
@@ -330,6 +330,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/trunk/sqlobject/mysql/mysqlconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2007-12-14 13:26:54 UTC (rev 3175)
+++ SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2007-12-14 13:27:08 UTC (rev 3176)
@@ -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", "conv"):
if key in kw:
@@ -45,9 +42,8 @@
else:
self.dbEncoding = None
if "sqlobject_encoding" in kw:
- self.encoding = kw.pop("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,9 +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)
-
return cursor.execute(query)
except MySQLdb.OperationalError, e:
if e.args[0] in (MySQLdb.constants.CR.SERVER_GONE_ERROR, MySQLdb.constants.CR.SERVER_LOST):
|