]> granicus.if.org Git - python/commitdiff
Run 2to3 over Doc/lib/sqlite3/.
authorCollin Winter <collinw@gmail.com>
Tue, 7 Aug 2007 01:20:21 +0000 (01:20 +0000)
committerCollin Winter <collinw@gmail.com>
Tue, 7 Aug 2007 01:20:21 +0000 (01:20 +0000)
22 files changed:
Doc/lib/sqlite3/adapter_datetime.py
Doc/lib/sqlite3/adapter_point_1.py
Doc/lib/sqlite3/adapter_point_2.py
Doc/lib/sqlite3/collation_reverse.py
Doc/lib/sqlite3/complete_statement.py
Doc/lib/sqlite3/converter_point.py
Doc/lib/sqlite3/countcursors.py
Doc/lib/sqlite3/execsql_fetchonerow.py
Doc/lib/sqlite3/execsql_printall_1.py
Doc/lib/sqlite3/execute_1.py
Doc/lib/sqlite3/execute_2.py
Doc/lib/sqlite3/execute_3.py
Doc/lib/sqlite3/executemany_1.py
Doc/lib/sqlite3/executemany_2.py
Doc/lib/sqlite3/md5func.py
Doc/lib/sqlite3/mysumaggr.py
Doc/lib/sqlite3/parse_colnames.py
Doc/lib/sqlite3/pysqlite_datetime.py
Doc/lib/sqlite3/row_factory.py
Doc/lib/sqlite3/shortcut_methods.py
Doc/lib/sqlite3/simple_tableprinter.py
Doc/lib/sqlite3/text_factory.py

index 34604985c124b586a603c408c9aff3ae04e2cabd..5869e22b32f58071bdf92b9624da9748d9c845da 100644 (file)
@@ -11,4 +11,4 @@ cur = con.cursor()
 
 now = datetime.datetime.now()
 cur.execute("select ?", (now,))
-print cur.fetchone()[0]
+print(cur.fetchone()[0])
index a741f6c25a191c4534237d27d947cfd4b67a425f..1343acde3cd19ed5db77903a917f9337936e187b 100644 (file)
@@ -13,4 +13,4 @@ cur = con.cursor()
 
 p = Point(4.0, -3.2)
 cur.execute("select ?", (p,))
-print cur.fetchone()[0]
+print(cur.fetchone()[0])
index 200a064eace7e1b7b0f76750275c1f167a14002d..1e1719a3cc0216cd94651deb5551d18819ec30a2 100644 (file)
@@ -14,4 +14,4 @@ cur = con.cursor()
 
 p = Point(4.0, -3.2)
 cur.execute("select ?", (p,))
-print cur.fetchone()[0]
+print(cur.fetchone()[0])
index e9564023d3d43d47e4f542905e2915ade0cffe76..bfd7f5bd9f0cf8fe918e5ee68c1ec3b6084c46bb 100644 (file)
@@ -11,5 +11,5 @@ cur.execute("create table test(x)")
 cur.executemany("insert into test(x) values (?)", [("a",), ("b",)])
 cur.execute("select x from test order by x collate reverse")
 for row in cur:
-    print row
+    print(row)
 con.close()
index 76ea7f6a66abc82c20a4c09217059f1971832fe8..cd38d7305bb69c33a2b981e7df1c22db13ce50e7 100644 (file)
@@ -8,11 +8,11 @@ cur = con.cursor()
 
 buffer = ""
 
-print "Enter your SQL commands to execute in sqlite3."
-print "Enter a blank line to exit."
+print("Enter your SQL commands to execute in sqlite3.")
+print("Enter a blank line to exit.")
 
 while True:
-    line = raw_input()
+    line = input()
     if line == "":
         break
     buffer += line
@@ -22,9 +22,9 @@ while True:
             cur.execute(buffer)
 
             if buffer.lstrip().upper().startswith("SELECT"):
-                print cur.fetchall()
+                print(cur.fetchall())
         except sqlite3.Error as e:
-            print "An error occurred:", e.args[0]
+            print("An error occurred:", e.args[0])
         buffer = ""
 
 con.close()
index e220e9b0807e2269598877dc3ec93e029e6ad1ad..d0707abd2e2cca4fbf3f4f3fe75cafae222fff00 100644 (file)
@@ -11,7 +11,7 @@ def adapt_point(point):
     return "%f;%f" % (point.x, point.y)
 
 def convert_point(s):
-    x, y = map(float, s.split(";"))
+    x, y = list(map(float, s.split(";")))
     return Point(x, y)
 
 # Register the adapter
@@ -30,7 +30,7 @@ cur.execute("create table test(p point)")
 
 cur.execute("insert into test(p) values (?)", (p,))
 cur.execute("select p from test")
-print "with declared types:", cur.fetchone()[0]
+print("with declared types:", cur.fetchone()[0])
 cur.close()
 con.close()
 
@@ -42,6 +42,6 @@ cur.execute("create table test(p)")
 
 cur.execute("insert into test(p) values (?)", (p,))
 cur.execute('select p as "p [point]" from test')
-print "with column names:", cur.fetchone()[0]
+print("with column names:", cur.fetchone()[0])
 cur.close()
 con.close()
index df04cad595fd9e52c1337f5940b8250e9c285451..ef3e70a2a9cfc5e61eb808ff1d1ab50a2ecf04ae 100644 (file)
@@ -12,4 +12,4 @@ class CountCursorsConnection(sqlite3.Connection):
 con = sqlite3.connect(":memory:", factory=CountCursorsConnection)
 cur1 = con.cursor()
 cur2 = con.cursor()
-print con.numcursors
+print(con.numcursors)
index 8044ecf95067740e9655e46afc2e4c3144558177..078873bfc979a94491bb0578ab691f5cd0e0662a 100644 (file)
@@ -9,9 +9,9 @@ SELECT = "select name_last, age from people order by age, name_last"
 # resulting sequences to yield their elements (name_last, age):
 cur.execute(SELECT)
 for (name_last, age) in cur:
-    print '%s is %d years old.' % (name_last, age)
+    print('%s is %d years old.' % (name_last, age))
 
 # 2. Equivalently:
 cur.execute(SELECT)
 for row in cur:
-    print '%s is %d years old.' % (row[0], row[1])
+    print('%s is %d years old.' % (row[0], row[1]))
index d27d735a2846dca97c2083dc5bb2aa33dde4e0e9..a4ce5c528149c5cdd68de5f9b3271f9e307623ff 100644 (file)
@@ -10,4 +10,4 @@ cur = con.cursor()
 cur.execute("select * from people order by age")
 
 # Retrieve all rows as a sequence and print that sequence:
-print cur.fetchall()
+print(cur.fetchall())
index fb3784ffb3bacc5aa9d13e5ffef4290af4ebc63f..3d08840b86c2d0ef56b65b48824eb41ca734aadf 100644 (file)
@@ -8,4 +8,4 @@ who = "Yeltsin"
 age = 72
 
 cur.execute("select name_last, age from people where name_last=? and age=?", (who, age))
-print cur.fetchone()
+print(cur.fetchone())
index df6c8940ebf3d97a4aaf2b34e97ee8cadbbd079c..84734f967ff715b6982f6f99931b4a5ecd24a5aa 100644 (file)
@@ -9,4 +9,4 @@ age = 72
 
 cur.execute("select name_last, age from people where name_last=:who and age=:age",
     {"who": who, "age": age})
-print cur.fetchone()
+print(cur.fetchone())
index b64621fc04b3ea1de7184aaf93bbb19e30be7b3e..0353683fc704764599475ea0287d82188cd4e32f 100644 (file)
@@ -9,4 +9,4 @@ age = 72
 
 cur.execute("select name_last, age from people where name_last=:who and age=:age",
     locals())
-print cur.fetchone()
+print(cur.fetchone())
index 2dc72cd2c5fef4637d9df1a1f708ed7f5bae74a0..efae10637c7e8f04624e85d064166c5ebbad442d 100644 (file)
@@ -21,4 +21,4 @@ theIter = IterChars()
 cur.executemany("insert into characters(c) values (?)", theIter)
 
 cur.execute("select c from characters")
-print cur.fetchall()
+print(cur.fetchall())
index 05857c0bde63c02a44d5fdec5c4f4d8b2b99bf8b..518cd9430d2dd1ab65ae9628f199be9b1f3892ae 100644 (file)
@@ -12,4 +12,4 @@ cur.execute("create table characters(c)")
 cur.executemany("insert into characters(c) values (?)", char_generator())
 
 cur.execute("select c from characters")
-print cur.fetchall()
+print(cur.fetchall())
index 5769687d9cb06e6478628267cfbe77785e9de158..b7bc05b379da79af60b2cbf63a44c3ecf2f6aa5a 100644 (file)
@@ -1,11 +1,11 @@
 import sqlite3
-import md5
+import hashlib
 
 def md5sum(t):
-    return md5.md5(t).hexdigest()
+    return hashlib.md5(t).hexdigest()
 
 con = sqlite3.connect(":memory:")
 con.create_function("md5", 1, md5sum)
 cur = con.cursor()
 cur.execute("select md5(?)", ("foo",))
-print cur.fetchone()[0]
+print(cur.fetchone()[0])
index 6d0cd551d593487d98c084993d6e62525ecc908b..d2dfd2c0b98d3b858b8c6ede6d02f4ca369064e3 100644 (file)
@@ -17,4 +17,4 @@ cur.execute("create table test(i)")
 cur.execute("insert into test(i) values (1)")
 cur.execute("insert into test(i) values (2)")
 cur.execute("select mysum(i) from test")
-print cur.fetchone()[0]
+print(cur.fetchone()[0])
index fcded00f3c29560f5310d20e4956192bc3f612ee..cc68c76459eceabe2ec868ac8b1f373d59f303cb 100644 (file)
@@ -5,4 +5,4 @@ con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES)
 cur = con.cursor()
 cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),))
 dt = cur.fetchone()[0]
-print dt, type(dt)
+print(dt, type(dt))
index efa4b06ceafaddbabb97111d379bce7324b863a6..68d49358a578b3b79888d01b9a3a2733d8e031b3 100644 (file)
@@ -11,10 +11,10 @@ now = datetime.datetime.now()
 cur.execute("insert into test(d, ts) values (?, ?)", (today, now))
 cur.execute("select d, ts from test")
 row = cur.fetchone()
-print today, "=>", row[0], type(row[0])
-print now, "=>", row[1], type(row[1])
+print(today, "=>", row[0], type(row[0]))
+print(now, "=>", row[1], type(row[1]))
 
 cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"')
 row = cur.fetchone()
-print "current_date", row[0], type(row[0])
-print "current_timestamp", row[1], type(row[1])
+print("current_date", row[0], type(row[0]))
+print("current_timestamp", row[1], type(row[1]))
index 64676c8f3f62648520b935389603737728bec13a..e436ffc6c80225f0db5e0286bb502197b441d6d9 100644 (file)
@@ -10,4 +10,4 @@ con = sqlite3.connect(":memory:")
 con.row_factory = dict_factory
 cur = con.cursor()
 cur.execute("select 1 as a")
-print cur.fetchone()["a"]
+print(cur.fetchone()["a"])
index 72ed4b3712c805e3e4239f82d3a92c2c1a4353ac..596d87c18e0cd113685bcae7ac11ef0ac1d7380f 100644 (file)
@@ -15,7 +15,7 @@ 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
+    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"
+print("I just deleted", con.execute("delete from person where 1=1").rowcount, "rows")
index 67ea6a2b192f3f453e1255df4e8cee945677a76b..231d8726cd436e30d998bac4cc113f0af5b08e29 100644 (file)
@@ -11,9 +11,9 @@ cur.execute(SELECT)
 
 # Print a header.
 for fieldDesc in cur.description:
-    print fieldDesc[0].ljust(FIELD_MAX_WIDTH) ,
-print # Finish the header with a newline.
-print '-' * 78
+    print(fieldDesc[0].ljust(FIELD_MAX_WIDTH), end=' ')
+print() # Finish the header with a newline.
+print('-' * 78)
 
 # For each row, print the value of each field left-justified within
 # the maximum possible width of that field.
@@ -21,6 +21,6 @@ fieldIndices = range(len(cur.description))
 for row in cur:
     for fieldIndex in fieldIndices:
         fieldValue = str(row[fieldIndex])
-        print fieldValue.ljust(FIELD_MAX_WIDTH) ,
+        print(fieldValue.ljust(FIELD_MAX_WIDTH), end=' ')
 
-    print # Finish the row with a newline.
+    print() # Finish the row with a newline.
index 3e157a8ea9f72f669ee4ad10d6e109d426a9c5eb..2dab8e453f95218db3c3ad0f3acb56124ee96b8a 100644 (file)
@@ -6,7 +6,7 @@ cur = con.cursor()
 # Create the table
 con.execute("create table person(lastname, firstname)")
 
-AUSTRIA = u"\xd6sterreich"
+AUSTRIA = "\xd6sterreich"
 
 # by default, rows are returned as Unicode
 cur.execute("select ?", (AUSTRIA,))
@@ -25,17 +25,17 @@ 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"),))
+con.text_factory = lambda x: str(x, "utf-8", "ignore")
+cur.execute("select ?", ("this is latin1 and would normally create errors" + "\xe4\xf6\xfc".encode("latin1"),))
 row = cur.fetchone()
-assert type(row[0]) == unicode
+assert type(row[0]) == str
 
 # 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
+assert type(row[0]) == str
 
 cur.execute("select ?", ("Germany",))
 row = cur.fetchone()