[SQL-CVS] r3173 - in SQLObject/branches/0.7: docs sqlobject/mysql
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2007-12-14 13:26:26
|
Author: phd Date: 2007-12-14 06:26:07 -0700 (Fri, 14 Dec 2007) New Revision: 3173 Modified: SQLObject/branches/0.7/docs/News.txt SQLObject/branches/0.7/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.7/docs/News.txt =================================================================== --- SQLObject/branches/0.7/docs/News.txt 2007-12-13 07:12:44 UTC (rev 3172) +++ SQLObject/branches/0.7/docs/News.txt 2007-12-14 13:26:07 UTC (rev 3173) @@ -13,6 +13,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.7/sqlobject/mysql/mysqlconnection.py =================================================================== --- SQLObject/branches/0.7/sqlobject/mysql/mysqlconnection.py 2007-12-13 07:12:44 UTC (rev 3172) +++ SQLObject/branches/0.7/sqlobject/mysql/mysqlconnection.py 2007-12-14 13:26:07 UTC (rev 3173) @@ -1,5 +1,6 @@ -from sqlobject.dbconnection import DBAPI from sqlobject import col +from sqlobject.dbconnection import DBAPI +from sqlobject.main import deprecated MySQLdb = None class MySQLConnection(DBAPI): @@ -11,7 +12,7 @@ def __init__(self, db, user, passwd='', host='localhost', port=None, **kw): global MySQLdb if MySQLdb is None: - import MySQLdb, MySQLdb.constants.CR, MySQLdb.constants.ER + import MySQLdb self.module = MySQLdb self.host = host self.port = port @@ -19,10 +20,6 @@ self.user = user self.password = passwd 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: @@ -36,9 +33,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): @@ -70,12 +66,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 @@ -86,13 +82,6 @@ def _executeRetry(self, conn, cursor, query): while 1: 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] == 2013: # SERVER_LOST error @@ -174,10 +163,10 @@ colClass = col.UnicodeCol 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'): |