Your exmaple above works ok if you add:
connection.query('set names utf8')
just after connection = ...
I've also tried to add
init_command="set names utf8" as a keyword argument to
connection = sqlobject.connectionForURI("mysql://*:[EMAIL PROTECTED]/*")
which supposedly should've been passed to MySQLdb.connect, but that
didn't work, SQLObject seems to mangle it to "set+names+utf8" for some
reason.
I also tried
#!/usr/bin/env python2.4
# -*- coding: utf-8 -*-
import sqlobject
connection =
sqlobject.connectionForURI("mysql://[EMAIL PROTECTED]/test")
connection.query('set names utf8')
sqlobject.sqlhub.processConnection = connection
class MyTestClass(sqlobject.SQLObject):
class sqlmeta:
table = 'test_unicode_table'
test_column = sqlobject.UnicodeCol(length = 5)
MyTestClass.dropTable()
MyTestClass.createTable()
test123 = MyTestClass(test_column =
u'\u0434\u0430\u043c\u0458\u0430\u043d')
print test123
print test123.test_column
(that's my name in cyrillic and it has 6 letters) but at the end I got
only 5 letters:
u'\u0434\u0430\u043c\u0458\u0430'
... which is good in a way since it's actually 12 bytes, so at least
the length=5 is handled properly.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---