Created
August 27, 2012 05:27
-
-
Save cheeplusplus/3485820 to your computer and use it in GitHub Desktop.
Sqlite issue with unicode strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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