Re: Subject: Pysqlite, APSW and unicode version

Gerhard Häring <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thorsten Kampe wrote:
> Hi,
> 
> I've written a script[1] that reads in CSV files, inserts the tables 
> into a database and fetches the records afterwards. The CSV files are 
> UTF-8 encoded (but they also could be any other encoding).
> 
> With psysqlite this all works fine while with APSW I have to decode 
> the UTF-8 byte strings before I can insert them into the database via 
> "executemany". So obviously pysqlite does the decoding transparently 
> (which probably is not good as the byte strings could have any 
> encoding).
> 
> How does does pysqlite know which encoding to use for byte strings for 
> execute (or executemany) statements?

SQLite strings are per definitionem UTF-8 encoded. There are no checks by
SQLite or pysqlite wether the bytestrings you use are actually UTF-8
encoded, but if they're not, chances are you'll get problems later on.

- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4yhZdIO4ozGCH14RAte8AKCgWUKulz0Qd5R9R9pMi6lPKMvtlQCgkxDf
o9Chfur2KC6MBtt2kqZMVRs=
=REGw
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.