summaryrefslogtreecommitdiffstats
path: root/Doc/lib/sqlite3/text_factory.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-08-15 14:26:55 (GMT)
committerGeorg Brandl <georg@python.org>2007-08-15 14:26:55 (GMT)
commitf56181ff53ba00b7bed3997a4dccd9a1b6217b57 (patch)
tree1200947a7ffc78c2719831e4c7fd900a8ab01368 /Doc/lib/sqlite3/text_factory.py
parentaf62d9abfb78067a54c769302005f952ed999f6a (diff)
downloadcpython-f56181ff53ba00b7bed3997a4dccd9a1b6217b57.zip
cpython-f56181ff53ba00b7bed3997a4dccd9a1b6217b57.tar.gz
cpython-f56181ff53ba00b7bed3997a4dccd9a1b6217b57.tar.bz2
Delete the LaTeX doc tree.
Diffstat (limited to 'Doc/lib/sqlite3/text_factory.py')
-rw-r--r--Doc/lib/sqlite3/text_factory.py42
1 files changed, 0 insertions, 42 deletions
diff --git a/Doc/lib/sqlite3/text_factory.py b/Doc/lib/sqlite3/text_factory.py
deleted file mode 100644
index 3e157a8..0000000
--- a/Doc/lib/sqlite3/text_factory.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import sqlite3
-
-con = sqlite3.connect(":memory:")
-cur = con.cursor()
-
-# Create the table
-con.execute("create table person(lastname, firstname)")
-
-AUSTRIA = u"\xd6sterreich"
-
-# by default, rows are returned as Unicode
-cur.execute("select ?", (AUSTRIA,))
-row = cur.fetchone()
-assert row[0] == AUSTRIA
-
-# but we can make pysqlite always return bytestrings ...
-con.text_factory = str
-cur.execute("select ?", (AUSTRIA,))
-row = cur.fetchone()
-assert type(row[0]) == str
-# the bytestrings will be encoded in UTF-8, unless you stored garbage in the
-# database ...
-assert row[0] == AUSTRIA.encode("utf-8")
-
-# we can also implement a custom text_factory ...
-# here we implement one that will ignore Unicode characters that cannot be
-# decoded from UTF-8
-con.text_factory = lambda x: unicode(x, "utf-8", "ignore")
-cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),))
-row = cur.fetchone()
-assert type(row[0]) == unicode
-
-# pysqlite offers a builtin optimized text_factory that will return bytestring
-# objects, if the data is in ASCII only, and otherwise return unicode objects
-con.text_factory = sqlite3.OptimizedUnicode
-cur.execute("select ?", (AUSTRIA,))
-row = cur.fetchone()
-assert type(row[0]) == unicode
-
-cur.execute("select ?", ("Germany",))
-row = cur.fetchone()
-assert type(row[0]) == str