#222 SQLObject 0.9: Unicode interaction problems with MySQLDb

closed
nobody
MySQL (29)
5
2007-08-13
2007-05-17
Anonymous
No

E-mail: elvis.pfutzenreuter@gmail.com

After upgrading to TurboGears 1.0.2.2, SQLObject 0.9 and MySQLdb 1.2.2 final, the Unicode problem still remains.

Changing line 32 of sqlobject/mysql/mysqlconnection.py, from

need_unicode = True

to

need_unicode = False

solves the problem, as it used to solve in older versions of TurboGears/SQLObject. Maybe it is a bug of MySQLdb, but the code I patched already seems to be a workaround :)

Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/cherrypy/_cphttptools.py", line 105, in _run
self.main()
File "/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/cherrypy/_cphttptools.py", line 254, in main
body = page_handler(*virtual_path, **self.params)
File "<string>", line 3, in fetch
File "/usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg/turbogears/controllers.py", line 336, in expose
*args, **kw)
File "<string>", line 5, in run_with_transaction
File "/usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg/turbogears/database.py", line 303, in so_rwt
retval = func(*args, **kw)
File "<string>", line 5, in _expose
File "/usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg/turbogears/controllers.py", line 351, in <lambda>
mapping, fragment, args, kw)))
File "/usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg/turbogears/controllers.py", line 378, in _execute_func
output = errorhandling.try_call(func, *args, **kw)
File "/usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg/turbogears/errorhandling.py", line 73, in try_call
return func(self, *args, **kw)
File "<string>", line 3, in fetch
File "/usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg/turbogears/controllers.py", line 173, in validate
return errorhandling.run_with_errors(errors, func, *args, **kw)
File "/usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg/turbogears/errorhandling.py", line 113, in run_with_errors
return func(self, *args, **kw)
File "/home/epx/luca/luca/sys_users.py", line 191, in fetch
return self.base_fetch(id)
File "/home/epx/luca/luca/simple_table.py", line 395, in base_fetch
grant.done(self.row_name(row))
File "/home/epx/luca/luca/mylib.py", line 69, in done
self._write()
File "/home/epx/luca/luca/mylib.py", line 38, in _write
user=current.user, err=self.logerr)
File "/usr/lib/python2.5/site-packages/SQLObject-0.9.0-py2.5.egg/sqlobject/declarative.py", line 94, in _wrapper
return fn(self, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/SQLObject-0.9.0-py2.5.egg/sqlobject/main.py", line 1214, in __init__
self._create(id, **kw)
File "/usr/lib/python2.5/site-packages/SQLObject-0.9.0-py2.5.egg/sqlobject/main.py", line 1245, in _create
self._SO_finishCreate(id)
File "/usr/lib/python2.5/site-packages/SQLObject-0.9.0-py2.5.egg/sqlobject/main.py", line 1269, in _SO_finishCreate
id, names, values)
File "/usr/lib/python2.5/site-packages/SQLObject-0.9.0-py2.5.egg/sqlobject/dbconnection.py", line 849, in queryInsertID
self._connection, soInstance, id, names, values)
File "/usr/lib/python2.5/site-packages/SQLObject-0.9.0-py2.5.egg/sqlobject/mysql/mysqlconnection.py", line 156, in _queryInsertID
self._executeRetry(conn, c, q)
File "/usr/lib/python2.5/site-packages/SQLObject-0.9.0-py2.5.egg/sqlobject/mysql/mysqlconnection.py", line 113, in _executeRetry
query = unicode(query, self.encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 90: ordinal not in range(128)

Discussion

  • Oleg Broytman
    Oleg Broytman
    2007-07-20

    Logged In: YES
    user_id=4799
    Originator: NO

    Does "charset=latin1" or "charset=utf-8" in your DB URI help?

     
  • Oleg Broytman
    Oleg Broytman
    2007-08-13

    • status: open --> closed