Re: [SQLObject] Another unicode / mysql related problem :(
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: sophana <so...@zi...> - 2006-09-28 11:17:23
|
What is you mysqldb version? I think I had this problem before. Don't remember what exactly solved the problem. Is your table set to utf-8? Mathias Winkler a =E9crit : > Hi list! > > I am stuck here with another unicode related problem: > > Whenever I add/update something to the database via html forms, every=20 > special character gets replaced with a question mark. (Maybe the=20 > replacement character?). When I change the data by hand by using=20 > CocoaMySql.app (which is quite encoding safe, I guess) text get=20 > displayed correctly. When I load the data into the form, it is still=20 > correct. But when I save the changes, i.e. use sqlobject to set the=20 > attributes, stuff gets replaced! When i debug the string the controller= =20 > returns > > I guess I tried everything that I read on this list, so sorry if I am t= o=20 > verbose, but I'm lost..: > > Here a snippet from my model.py: > <--- > class NewsItem (SQLObject): > date=3DDateCol() > headline=3DUnicodeCol() > body=3DUnicodeCol() > ---> > > My MySql server's variables 'character_set_*' is set to utf-8 (the onl= y=20 > exception is the character_set_server which is latin-1). > > site.py sets the sys.defaultencoding to 'utf-8'. > > I tried the unit._connection.query SET NAMES thingie. > > My connection uri is something ending with=20 > 'use_unicode=3D1&debug=3D1&sqlobject_encoding=3Dutf8&charset=3Dutf8' > > My xml encoding for the the html is utf-8. > > > When trying things in ipython the following happens: > > In [7]: x.headline =3D u'\xd6sterreichs gr\xf6\xdfter' > 1/Query : UPDATE news_item SET headline =3D ('=D6sterreichs gr=F6=DF= ter')=20 > WHERE id =3D (5) > /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-pa= ckages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/mysql/mysqlconnection= .py:75:=20 > Warning: Data truncated for column 'headline' at row 1 > return cursor.execute(myquery) > > I don't know if the encoding of the query string comes thru alright, bu= t=20 > its looks perfect here. > > > > > here is some other "interesting" code snippet: > <-- > NewsItem._connection.query("SET NAMES utf8") # hope never d= ies > item=3DNewsItem.get(id) > log.debug("writing headline as: %s" % repr(headline)) > item.headline=3Dheadline > log.debug("written headline is: %s" %=20 > repr(item.headline)) =20 > --> > > produces a good-looking debug output like that: > > <-- > 2006-09-28 02:03:37,380 bogi.controllers DEBUG writing headline as:=20 > u'ooo\xf6\xf6\xf6ooo' > 2006-09-28 02:03:37,393 bogi.controllers DEBUG written headline is:=20 > u'ooo\xf6\xf6\xf6ooo' > --> > > still it doesn't work and get saved into the db as "ooo???ooo" > > > > > I've spent soo many hours figuring things out, but I just can't get it=20 > work correctly. So please help me, if you can! > > > Mathias. > > > > -----------------------------------------------------------------------= -- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share= your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > > =20 |