This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author loewis
Recipients amaury.forgeotdarc, izarf, loewis
Date 2009-05-13.18:37:31
SpamBayes Score 2.263874e-06
Marked as misclassified No
Message-id <1242239854.47.0.065819326354.issue6010@psf.upfronthosting.co.za>
In-reply-to
Content
This is not a bug. By default, pysqlite decodes all strings to Unicode,
assuming UTF-8 encoding (which SQLite assumes when parsing statements).

To override this default, you need to change the connection's text_factory:

py> import sqlite3
py> db = sqlite3.connect(':memory:')
py> db.text_factory = str
py> cur = db.cursor()
py> cur.execute("create table foo (x)")
<sqlite3.Cursor object at 0xb7cfb500>
py> cur.execute("insert into foo values ('café')")
<sqlite3.Cursor object at 0xb7cfb500>
py> cur.execute("select * from foo")
<sqlite3.Cursor object at 0xb7cfb500>
py> _.fetchall()
[('caf\xe9',)]
History
Date User Action Args
2009-05-13 18:37:34loewissetrecipients: + loewis, amaury.forgeotdarc, izarf
2009-05-13 18:37:34loewissetmessageid: <1242239854.47.0.065819326354.issue6010@psf.upfronthosting.co.za>
2009-05-13 18:37:32loewislinkissue6010 messages
2009-05-13 18:37:31loewiscreate