Hi,

I think I found the solution.  The trick is to specify both, the
charset and the sqlobject_encoding as parameters in the connection
URI: ?use_unicode=1&charset=utf8&sqlobject_encoding=utf-8

By using this, the following example works fine.  The data in the DB
is also stored in the desired (utf-8) encoding.  To prevent from any
confusion about file-encoding and using u'', I choose to have the file
ASCII-encoded and use \u escapes in the unicode string :)

Thanks for the help,
Markus


from sqlobject import *

sqlhub.processConnection = connectionForURI(
   'mysql://[EMAIL 
PROTECTED]/test?use_unicode=1&charset=utf8&sqlobject_encoding=utf-8')

class Test(SQLObject):
   name = UnicodeCol()

Test.dropTable(ifExists=True)
Test.createTable(ifNotExists=True)

# In HTML 4 this would be: ä ö ü €
Test(name=u'\u00E4 \u00F6 \u00FC \u20AC ')

print Test.get(1).name.encode('utf-8') # Needs an utf-8 capable terminal

Attachment: success.png
Description: PNG image

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to