Patches item #1653898, was opened at 2007-02-07 09:57
Message generated for change (Comment added) made by mfi
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1653898&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Maxim F. Ischenko (mfi)
Assigned to: Oleg Broytmann (phd)
Summary: proper init mysql conn encoding
Initial Comment:
Current implementation of the mysqlconnection.py accepts 'sqlobject_encoding' and 'charset' parameters but doesn't quite properly use them.
In particular, MySQLdb does query.encode(charset) call in execute() where charset is taken from conn.get_character_name(). The problem is - SQLObject never initializes it properly.
This one-line patch fixes it by adding a call to conn.set_character_set() in makeConnection() helper.
Index: sqlobject/mysql/mysqlconnection.py
===================================================================
--- sqlobject/mysql/mysqlconnection.py (revision 2269)
+++ sqlobject/mysql/mysqlconnection.py (working copy)
@@ -62,6 +62,8 @@
if hasattr(conn, 'autocommit'):
conn.autocommit(bool(self.autoCommit))
+ conn.set_character_set(self.encoding)
+
return conn
def _setAutoCommit(self, conn, auto):
----------------------------------------------------------------------
>Comment By: Maxim F. Ischenko (mfi)
Date: 2007-02-07 16:46
Message:
Logged In: YES
user_id=113894
Originator: YES
It was tested against MySQL 4.1 (5.x should work while 4.0 shouldn't) and
MySQLdb driver versions 1.2.0 and 1.2.1. I only tested it with utf8
encoding, the other ones like latin1 should work though I don't know why
would you want to use them.
----------------------------------------------------------------------
Comment By: Maxim F. Ischenko (mfi)
Date: 2007-02-07 16:44
Message:
Logged In: YES
user_id=113894
Originator: YES
Please ignore that one-line fix; it won't work with MySQLdb 1.2.0 and
there are other issues as I have discovered during testing. I attached new
patch which is quite more involved. ;)
----------------------------------------------------------------------
Comment By: Maxim F. Ischenko (mfi)
Date: 2007-02-07 16:42
Message:
Logged In: YES
user_id=113894
Originator: YES
File Added: mysql_charset.patch
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2007-02-07 10:34
Message:
Logged In: YES
user_id=4799
Originator: NO
Thank you. Does all MySQLdb versions have the call or have I test "if
hasattr(conn, 'set_character_set')"?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1653898&group_id=74338
|