Re: [pysqlite] Encoding for connect to SqLite3
Gerhard Häring <[email protected]> Thu, 25 Jun 2009 19:54:36 +0200
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Hello, I'll cc the mailing list. Please direct future questions there. PY-Delens wrote: > Bonjour, > > I fail to display correctly accentuated characters from aSqLite 3 table > (stored in UTF-8 after abandoned UTF-16 scenario). > I try to add parameter _/encoding /_to thre PySqlite connect function, > but this is refused: [...] No surprise. pysqlite doesn't have an encoding parameter anywhere. To store text that is not UTF8 encoded, you can achieve that using your custom text_factory (See http://oss.itsystementwicklung.de/download/pysqlite/doc/sqlite3.html). > I'm alo confused on the libs supposed to be called in PySqlite; probably > one is nested into the other: > pysqlite2 > Sqlite3 [...] pysqlite2 is the Python wrapper for the SQLite 3 library, which is the embedded database engine. If you use Python 2.5 or later, a version of pysqlite2 is available under the module name "sqlite3" as well. > How should I do? How to handle the encoding problem at: > - Python module level > - SQL string level > - DATA in SqLite file (I was advised to go back to UTF-8, by people > of DbManager tools) > ? I'd recommend to use UTF8 only. If you don't, you'll need to use bytestrings in your encoding as parameters to execute(). And set a text_factory that converts them back. If you just want the same bytestrings back (instead of, say, unicode string objects), you can just use text_factory=str. -- Gerhard