Hi guys,

I'm facing problems with charsets, I have a fedora box with:

 * python2.4
 * MySQL-python-1.2.1_p2
 * SQLObject-0.7.1dev_r1728
 * MySQL 4.1.16

I have the following class...

class Player(SQLObject):
    name = StringCol(length=200)

...and I try to instantiate some values:

p1 = Player(name='Garrincha') # this insertion works ok
p2 = Player(name='Pelé') # this doesn't work, above the exception
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File ".../sqlobject/declarative.py", line 92, in _wrapper
   return_value = fn(self, *args, **kwargs)
 File ".../sqlobject/main.py", line 1197, in __init__
   self._create(id, **kw)
 File ".../sqlobject/main.py", line 1224, in _create
   self._SO_finishCreate(id)
 File ".../sqlobject/main.py", line 1248, in _SO_finishCreate
   id, names, values)
 File ".../sqlobject/dbconnection.py", line 359, in queryInsertID
   return self._runWithConnection(self._queryInsertID, soInstance,
id, names, values)
 File ".../sqlobject/dbconnection.py", line 219, in _runWithConnection
   val = meth(conn, *args)
 File ".../sqlobject/mysql/mysqlconnection.py", line 78, in _queryInsertID
   self._executeRetry(conn, c, q)
 File ".../sqlobject/mysql/mysqlconnection.py", line 60, in _executeRetry
   return cursor.execute(query)
 File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line
147, in execute
   query = query.encode(charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
38: ordinal not in range(128)

p2 = Player(name=u'Pelé') # now I try a unicode string, another error
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File ".../sqlobject/declarative.py", line 92, in _wrapper
   return_value = fn(self, *args, **kwargs)
 File ".../sqlobject/main.py", line 1197, in __init__
   self._create(id, **kw)
 File ".../sqlobject/main.py", line 1221, in _create
   self.set(**kw)
 File ".../sqlobject/main.py", line 1080, in set
   kw[name] = dbValue = from_python(value, self._SO_validatorState)
 File ".../sqlobject/col.py", line 519, in from_python
   return value.encode("ascii")
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 3: ordinal not in range(128)

I try to use UnicodeCol instead StringCol in the class definition
without success, I try to specify the charset at mysql using "set
names 'latin1'" or "set names 'utf8'" without success too. I inserted
data by hand through mysql console and it was ok, but I was unable to
select data.

How can I use my charset with sqlobject/mysql? Thanks in advance...

--
Michel Thadeu Sabchuk
Curitiba - Brasil


-------------------------------------------------------
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&kid0709&bid&3057&dat1642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to