[Python-checkins] r45876 - in python/trunk: Doc/lib/sqlite3/adapter_point_1.py Doc/lib/sqlite3/adapter_point_2.py Doc/lib/sqlite3/execute_2.py Doc/lib/sqlite3/execute_3.py Doc/lib/sqlite3/insert_more_people.py Doc/lib/sqlite3/shortcut_methods.py Doc/lib/sqlite3/text_factory.py Lib/test/test_unicode.py
tim.peters
python-checkins at python.org
Wed May 3 06:46:15 CEST 2006
Author: tim.peters
Date: Wed May 3 06:46:14 2006
New Revision: 45876
Modified:
python/trunk/Doc/lib/sqlite3/adapter_point_1.py
python/trunk/Doc/lib/sqlite3/adapter_point_2.py
python/trunk/Doc/lib/sqlite3/execute_2.py
python/trunk/Doc/lib/sqlite3/execute_3.py
python/trunk/Doc/lib/sqlite3/insert_more_people.py
python/trunk/Doc/lib/sqlite3/shortcut_methods.py
python/trunk/Doc/lib/sqlite3/text_factory.py
python/trunk/Lib/test/test_unicode.py
Log:
Whitespace normalization.
Modified: python/trunk/Doc/lib/sqlite3/adapter_point_1.py
==============================================================================
--- python/trunk/Doc/lib/sqlite3/adapter_point_1.py (original)
+++ python/trunk/Doc/lib/sqlite3/adapter_point_1.py Wed May 3 06:46:14 2006
@@ -14,4 +14,3 @@
p = Point(4.0, -3.2)
cur.execute("select ?", (p,))
print cur.fetchone()[0]
-
Modified: python/trunk/Doc/lib/sqlite3/adapter_point_2.py
==============================================================================
--- python/trunk/Doc/lib/sqlite3/adapter_point_2.py (original)
+++ python/trunk/Doc/lib/sqlite3/adapter_point_2.py Wed May 3 06:46:14 2006
@@ -15,4 +15,3 @@
p = Point(4.0, -3.2)
cur.execute("select ?", (p,))
print cur.fetchone()[0]
-
Modified: python/trunk/Doc/lib/sqlite3/execute_2.py
==============================================================================
--- python/trunk/Doc/lib/sqlite3/execute_2.py (original)
+++ python/trunk/Doc/lib/sqlite3/execute_2.py Wed May 3 06:46:14 2006
@@ -10,4 +10,3 @@
cur.execute("select name_last, age from people where name_last=:who and age=:age",
{"who": who, "age": age})
print cur.fetchone()
-
Modified: python/trunk/Doc/lib/sqlite3/execute_3.py
==============================================================================
--- python/trunk/Doc/lib/sqlite3/execute_3.py (original)
+++ python/trunk/Doc/lib/sqlite3/execute_3.py Wed May 3 06:46:14 2006
@@ -10,5 +10,3 @@
cur.execute("select name_last, age from people where name_last=:who and age=:age",
locals())
print cur.fetchone()
-
-
Modified: python/trunk/Doc/lib/sqlite3/insert_more_people.py
==============================================================================
--- python/trunk/Doc/lib/sqlite3/insert_more_people.py (original)
+++ python/trunk/Doc/lib/sqlite3/insert_more_people.py Wed May 3 06:46:14 2006
@@ -14,4 +14,3 @@
# The changes will not be saved unless the transaction is committed explicitly:
con.commit()
-
Modified: python/trunk/Doc/lib/sqlite3/shortcut_methods.py
==============================================================================
--- python/trunk/Doc/lib/sqlite3/shortcut_methods.py (original)
+++ python/trunk/Doc/lib/sqlite3/shortcut_methods.py Wed May 3 06:46:14 2006
@@ -1,22 +1,21 @@
-import sqlite3
-
-persons = [
- ("Hugo", "Boss"),
- ("Calvin", "Klein")
- ]
-
-con = sqlite3.connect(":memory:")
-
-# Create the table
-con.execute("create table person(firstname, lastname)")
-
-# Fill the table
-con.executemany("insert into person(firstname, lastname) values (?, ?)", persons)
-
-# Print the table contents
-for row in con.execute("select firstname, lastname from person"):
- print row
-
-# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.
-print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows"
-
+import sqlite3
+
+persons = [
+ ("Hugo", "Boss"),
+ ("Calvin", "Klein")
+ ]
+
+con = sqlite3.connect(":memory:")
+
+# Create the table
+con.execute("create table person(firstname, lastname)")
+
+# Fill the table
+con.executemany("insert into person(firstname, lastname) values (?, ?)", persons)
+
+# Print the table contents
+for row in con.execute("select firstname, lastname from person"):
+ print row
+
+# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.
+print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows"
Modified: python/trunk/Doc/lib/sqlite3/text_factory.py
==============================================================================
--- python/trunk/Doc/lib/sqlite3/text_factory.py (original)
+++ python/trunk/Doc/lib/sqlite3/text_factory.py Wed May 3 06:46:14 2006
@@ -1,43 +1,42 @@
-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
-
+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
Modified: python/trunk/Lib/test/test_unicode.py
==============================================================================
--- python/trunk/Lib/test/test_unicode.py (original)
+++ python/trunk/Lib/test/test_unicode.py Wed May 3 06:46:14 2006
@@ -410,7 +410,7 @@
def __str__(self):
return u'\u1234'
self.assertEqual('%s' % Wrapper(), u'\u1234')
-
+
@test_support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR')
def test_format_float(self):
# should not format with a comma, but always with C locale
More information about the Python-checkins
mailing list