sqlite3 and UTF-8

Ale Ghelfi grappale at hotmail.it
Tue Dec 7 11:37:37 EST 2010


i try this :

> actual_encoding = ... # whatever
> def decode(s):
>      return s.decode(actual_encoding)
>
> db = sqlite3.connect(...)
> db.text_factory = decode

but now the error is :

 >>> rowset = cur.fetchall()
Traceback (most recent call last):
   File "<pyshell#40>", line 1, in <module>
     rowset = cur.fetchall()
   File "<pyshell#34>", line 2, in decode
     return s.decode(enc)
   File "/usr/lib/python2.6/encodings/utf_8.py", line 16, in decode
     return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 33: 
invalid start byte



More information about the Python-list mailing list