Hi, everybody. I am new in Python and Sqlite and I have a problem when I'm
using unicode strings. Actually I'm working with WxPython and pysqlite (to
connect to sqlite).
The problem is as follows:
When I execute this:
cursor.execute('INSERT INTO names1 (id,decr,type)
VALUES (null,Βασίλης,7)')
everything works fine.
The values are stored in the table and when I retrieve them (select * from
names1...), everything is OK. (If you cannot read the literal value: is in
Greek). The values are shown in a wxpython list control perfect.
But...
When I ask a value from the user and I try to store it into the same table,
I run the following code
item=dialog.GetValue()
table=names1
cols=id,descr,type
values=(null,item,3)
a=insert into %s (%s) values %s % (table,cols,values)
cursor.execute(a)
and I get the error:
pysqlite2.dbapi2.OperationalError: near
'\u03b1\u03bd\u03c4\u03ce\u03bd\u03b7\u03c2': syntax error
I do understand that this one happens because item=
u'\u03b1\u03bd\u03c4\u03ce\u03bd\u03b7\u03c2'.
But how can I go trhought this???
I tried to use: values=(null,item.encode('utf-8'),3). The result is that
I store in the database the string without u in front of the string
('\u03b1\u03bd\u03c4\u03ce\u03bd\u03b7\u03c2') but...
When I execute Select * from names1... then I get this as the string I
stored:
'\u03b1\u03bd\u03c4\u03ce\u03bd\u03b7\u03c2'
and not the equivalent unicode string.
Can anybody help?
--
View this message in context:
http://www.nabble.com/Python-Sqlite-Unicode-characters-tf3486826.html#a9735074
Sent from the SQLite mailing list archive at Nabble.com.
-
To unsubscribe, send email to [EMAIL PROTECTED]
-