]> granicus.if.org Git - python/commitdiff
Whitespace normalization.
authorTim Peters <tim.peters@gmail.com>
Wed, 3 May 2006 04:46:14 +0000 (04:46 +0000)
committerTim Peters <tim.peters@gmail.com>
Wed, 3 May 2006 04:46:14 +0000 (04:46 +0000)
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

index 7b0c51e47eda8f0d85ddf509028ef3aa5427928c..b4856d59e7df392c39c32b5fed2055cf3770a9ee 100644 (file)
@@ -14,4 +14,3 @@ cur = con.cursor()
 p = Point(4.0, -3.2)\r
 cur.execute("select ?", (p,))\r
 print cur.fetchone()[0]\r
-\r
index 3b4ab101049dee0de51e54a978c7dce7bcf5ae5e..50e36926b5a1f57fd9a56ec2bc8f75809c10ba3d 100644 (file)
@@ -15,4 +15,3 @@ cur = con.cursor()
 p = Point(4.0, -3.2)\r
 cur.execute("select ?", (p,))\r
 print cur.fetchone()[0]\r
-\r
index 28318cc0165c4c9c418d0291c759d64a73e1f765..b4333d879c56fe344d2aaac454d4f6400e03a6f3 100644 (file)
@@ -10,4 +10,3 @@ age = 72
 cur.execute("select name_last, age from people where name_last=:who and age=:age",\r
     {"who": who, "age": age})\r
 print cur.fetchone()\r
-\r
index 2f02372e4edb6726cbdfb7ee524818af3a97d222..9cd3deb6ee865c8cb6dc1b92c4ac8d37f0a14a5b 100644 (file)
@@ -10,5 +10,3 @@ age = 72
 cur.execute("select name_last, age from people where name_last=:who and age=:age",\r
     locals())\r
 print cur.fetchone()\r
-\r
-\r
index 7daa88bd4c624c1ef32030682f3c71476a944eae..430d942053cca903f16cb567fd766730e1340d40 100644 (file)
@@ -14,4 +14,3 @@ for person in newPeople:
 \r
 # The changes will not be saved unless the transaction is committed explicitly:\r
 con.commit()\r
-\r
index 93c9547d8f739ae620b63d09d5b79f62ac4fc33c..12ce0c005b5ca58218a912cf9b2d4f3a812878f3 100644 (file)
@@ -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\r
+\r
+persons = [\r
+    ("Hugo", "Boss"),\r
+    ("Calvin", "Klein")\r
+    ]\r
+\r
+con = sqlite3.connect(":memory:")\r
+\r
+# Create the table\r
+con.execute("create table person(firstname, lastname)")\r
+\r
+# Fill the table\r
+con.executemany("insert into person(firstname, lastname) values (?, ?)", persons)\r
+\r
+# Print the table contents\r
+for row in con.execute("select firstname, lastname from person"):\r
+    print row\r
+\r
+# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.\r
+print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows"\r
index cf2ae92bde7c56d6385b64ebcf443f078cc27c69..13c832d3446a7374857247334321741b81c703b7 100644 (file)
@@ -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\r
+\r
+con = sqlite3.connect(":memory:")\r
+cur = con.cursor()\r
+\r
+# Create the table\r
+con.execute("create table person(lastname, firstname)")\r
+\r
+AUSTRIA = u"\xd6sterreich"\r
+\r
+# by default, rows are returned as Unicode\r
+cur.execute("select ?", (AUSTRIA,))\r
+row = cur.fetchone()\r
+assert row[0] == AUSTRIA\r
+\r
+# but we can make pysqlite always return bytestrings ...\r
+con.text_factory = str\r
+cur.execute("select ?", (AUSTRIA,))\r
+row = cur.fetchone()\r
+assert type(row[0]) == str\r
+# the bytestrings will be encoded in UTF-8, unless you stored garbage in the\r
+# database ...\r
+assert row[0] == AUSTRIA.encode("utf-8")\r
+\r
+# we can also implement a custom text_factory ...\r
+# here we implement one that will ignore Unicode characters that cannot be\r
+# decoded from UTF-8\r
+con.text_factory = lambda x: unicode(x, "utf-8", "ignore")\r
+cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),))\r
+row = cur.fetchone()\r
+assert type(row[0]) == unicode\r
+\r
+# pysqlite offers a builtin optimized text_factory that will return bytestring\r
+# objects, if the data is in ASCII only, and otherwise return unicode objects\r
+con.text_factory = sqlite3.OptimizedUnicode\r
+cur.execute("select ?", (AUSTRIA,))\r
+row = cur.fetchone()\r
+assert type(row[0]) == unicode\r
+\r
+cur.execute("select ?", ("Germany",))\r
+row = cur.fetchone()\r
+assert type(row[0]) == str\r
index 2858d1dbf96e216a43fd0e19d856c3492c1e4da2..34f9371658bfa1a918938c53ade01db92dea70e0 100644 (file)
@@ -410,7 +410,7 @@ class UnicodeTest(
             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