using Python3 and sqlite3 with complex unicode strings
I have to store complex unicode strings like "ʘ̃" (an IPA symbol) in a database. These strings involve peculiar characters, like k͡p with unusual diacritics. I decided to use sqlite3 and wrote the following lines in order to create my database :
import sqlite3 conn = sqlite3.connect('/tmp/example.db') c = conn.cursor() c.execute('create table mytable (mystring unicode)') c.execute("insert into mytable values ('ʘ̃ʘ͡qʘ͡qʼ)")
Then I read 'mytable' with these instructions :
c.execute('select * from mytable order by trans') for row in c: print(c)
But I get only an ill-formed string with missing characters while the most simple characters in my string remain. The same code works perfectly well with usual characters (like é, â, ö, ...). This code comes from the Python 3.2.3 documentation. Is sqlite3 not able to store ANY unicode character ?
Any help would be greatly appreciated !
PS : my file uses utf-8 encoding :
# -*- coding: utf-8 -*-
Sorry for the inconvenience but my code works perfectly well : it was my terminal that displayed wrong informations about the values returned by sqlite.