Skip to content

Instantly share code, notes, and snippets.

@cheeplusplus
Created August 27, 2012 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheeplusplus/3485820 to your computer and use it in GitHub Desktop.
Save cheeplusplus/3485820 to your computer and use it in GitHub Desktop.
Sqlite issue with unicode strings
# coding=utf8
import sqlite3
# Read ourselves, here is a failing character: é
file = open("unicodeissue.py", "r")
text = file.read()
file.close()
args = {"Value": text}
# Open sqlite db in memory
conn = sqlite3.connect(":memory:")
cursor = conn.cursor()
# Create table and add values
cursor.execute("CREATE TABLE test (_id integer PRIMARY KEY, Value text)");
cursor.execute("INSERT INTO test VALUES (NULL, :Value)", args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment