Dear Nadav,

     try using the connection string with use_unicode parameter
e.g.
connString = "mysql://root:[EMAIL PROTECTED]/test?use_unicode=1"
__connection__ = connectionForURI(connString)
     

Saturday, July 8, 2006, 12:54:35 PM, you wrote:

NS> Hi,

NS> I am using SQLObject-0.8dev_r1814, MySQLdb 1.2.1_p2 and MySQL 5.0.22
NS> on Arch Linux.
NS> I am using fields of type UnicodeCol. When I try to insert such object
NS> to the database I get
NS> an exception which originates in MySQLdb:

NS>   File
NS> 
"/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1814-py2.4.egg/sqlobject/mysql/mysqlconnection.py",
NS> line 66, in _executeRetry
NS>     return cursor.execute(query)
NS>   File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line
NS> 146, in execute
NS>     query = query.encode(charset)
NS> UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position
NS> 196: ordinal not in range(128)

NS> I tried to pass the data both as unicode strings and as normal strings
NS> with utf8 encoding.

NS> It seems like SQLObject is sending the query to MySQLdb as a normal
NS> string, encoded in utf8. But, MySQLdb excepts it to be a unicode
NS> string, because lines 145-156 in cursors.py are:

NS>         charset = db.character_set_name()
NS>         query = query.encode(charset)

NS> Also, it turns out that the value of charset is 'latin1'. I am not
NS> sure why it is so, but I could force it to be 'utf8' if I changed the
NS> connect() call in makeConnection() method of mysqlconnection.py to
NS> have a keyword argument charset='utf8'.
NS> Of course it does not help, since SQLObject already sends an encoded string.

NS> Any Ideas?

NS> Thanks,
NS> Nadav

NS> Using Tomcat but need to do more? Need to support web services, security?
NS> Get stuff done quickly with pre-integrated technology to make your job 
easier
NS> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
NS> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
NS> _______________________________________________
NS> sqlobject-discuss mailing list
NS> sqlobject-discuss@lists.sourceforge.net
NS> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss



-- 
Best regards,
 Ivan Horvath
 Chief Programmer

 Alcatel ISD
 PMS 2000 Product Team

 H-1116, Budapest
 Kondorfa u. 10.
 Tel.: +36 1 209 9546
 Fax.: +36 1 209 9599
 Mobil: +36 30 257 0235
 VOIP: +49 511 676 478010
 mailto:[EMAIL PROTECTED]

Anyone who has never made a mistake has never tried anything new.

/Albert Einstein/ 



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to