On Thu, May 10, 2007 at 11:09:19AM +0200, Markus Gritsch wrote:
> File
>
> "C:\Python25\lib\site-packages\SQLObject-0.9.0b2-py2.5.egg\sqlobject\mysql\mysqlconnection.py",
> line 82, in makeConnection
> conn.set_character_set(self.dbEncoding)
> File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line
> 277, in set_character_set
> super(Connection, self).set_character_set(charset)
> TypeError: argument 1 must be string, not None
Thank you. Does the attached patch help?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
Index: mysqlconnection.py
===================================================================
--- mysqlconnection.py (revision 2658)
+++ mysqlconnection.py (working copy)
@@ -57,13 +57,14 @@
connectionFromURI = classmethod(connectionFromURI)
def makeConnection(self):
- from MySQLdb.connections import Connection
- if not hasattr(Connection, 'set_character_set'):
- # monkeypatch pre MySQLdb 1.2.1
- encoding = self.dbEncoding
- def character_set_name(self):
- return encoding + '_' + encoding
- Connection.character_set_name = character_set_name
+ encoding = self.dbEncoding
+ if encoding:
+ from MySQLdb.connections import Connection
+ if not hasattr(Connection, 'set_character_set'):
+ # monkeypatch pre MySQLdb 1.2.1
+ def character_set_name(self):
+ return encoding + '_' + encoding
+ 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)
@@ -78,11 +79,12 @@
if hasattr(conn, 'autocommit'):
conn.autocommit(bool(self.autoCommit))
- if hasattr(conn, 'set_character_set'): # MySQLdb 1.2.1 and later
- conn.set_character_set(self.dbEncoding)
- else: # pre MySQLdb 1.2.1
- # works along with monkeypatching code above
- conn.query("SET NAMES %s" % self.dbEncoding)
+ if self.dbEncoding:
+ if hasattr(conn, 'set_character_set'): # MySQLdb 1.2.1 and later
+ conn.set_character_set(self.dbEncoding)
+ else: # pre MySQLdb 1.2.1
+ # works along with monkeypatching code above
+ conn.query("SET NAMES %s" % self.dbEncoding)
return conn
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss