I'm using SQLite with SQLObject 0.6, and I need to store and retrieve
unicode values. From my testing, I can get PySQLite to do unicode like
cx = sqlite.connect(":memory:", encoding="utf-8")
cu = cx.cursor()
cu.execute("create table test(myfield unicode)")
cu.execute(u"insert into test values (%s)", (u"\x99sterreich",))
cu.execute("select * from test")
value = cu.fetchone()
assert type(value) == unicode
(This is almost straight out of the PySQLite doc... I wanted to get it
confirmed in a test in my code).
The first problem is the SQLiteConnection does not provide a way for
me to set the encoding for the connection. I've tested this, and it is
required in order to successfully do unicode in both directions.
The second problem is that the column type needs to be unicode. If
it's just "text", PySQLite returns standard strings.
SQLiteConnection can be patched to add an optional encoding parameter.
Does that seem like something folks would want? If not, maybe I could
subclass SQLiteConnection and redo __init__ to open a unicode
For the second problem, I spotted a fairly recent thread
even with code (http://sourceforge.net/mailarchive/message.php?msg_id=10177526)
about making a unicode column. It also appears that there will be a
unicode column in 0.6.1. It seems like the main thing I need is to set
the column type.
My app is not going to be in production for a couple of months, so I
don't mind using alpha or beta code. I'm just looking for the "right"
way to do this in the context of SQLObject.