diff -r 8296b686c6de Doc/includes/sqlite3/adapter_datetime.py --- a/Doc/includes/sqlite3/adapter_datetime.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/adapter_datetime.py Thu Nov 01 14:00:45 2012 -0500 @@ -10,5 +10,5 @@ cur = con.cursor() now = datetime.datetime.now() -cur.execute("select ?", (now,)) +cur.execute("SELECT ?", (now,)) print cur.fetchone()[0] diff -r 8296b686c6de Doc/includes/sqlite3/adapter_point_1.py --- a/Doc/includes/sqlite3/adapter_point_1.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/adapter_point_1.py Thu Nov 01 14:00:45 2012 -0500 @@ -12,5 +12,5 @@ cur = con.cursor() p = Point(4.0, -3.2) -cur.execute("select ?", (p,)) +cur.execute("SELECT ?", (p,)) print cur.fetchone()[0] diff -r 8296b686c6de Doc/includes/sqlite3/adapter_point_2.py --- a/Doc/includes/sqlite3/adapter_point_2.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/adapter_point_2.py Thu Nov 01 14:00:45 2012 -0500 @@ -13,5 +13,5 @@ cur = con.cursor() p = Point(4.0, -3.2) -cur.execute("select ?", (p,)) +cur.execute("SELECT ?", (p,)) print cur.fetchone()[0] diff -r 8296b686c6de Doc/includes/sqlite3/collation_reverse.py --- a/Doc/includes/sqlite3/collation_reverse.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/collation_reverse.py Thu Nov 01 14:00:45 2012 -0500 @@ -7,9 +7,9 @@ con.create_collation("reverse", collate_reverse) cur = con.cursor() -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") +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 con.close() diff -r 8296b686c6de Doc/includes/sqlite3/converter_point.py --- a/Doc/includes/sqlite3/converter_point.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/converter_point.py Thu Nov 01 14:00:45 2012 -0500 @@ -26,10 +26,10 @@ # 1) Using declared types con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES) cur = con.cursor() -cur.execute("create table test(p point)") +cur.execute("CREATE TABLE test(p point)") -cur.execute("insert into test(p) values (?)", (p,)) -cur.execute("select p from test") +cur.execute("INSERT INTO test(p) VALUES (?)", (p,)) +cur.execute("SELECT p FROM test") print "with declared types:", cur.fetchone()[0] cur.close() con.close() @@ -38,10 +38,10 @@ # 1) Using column names con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) cur = con.cursor() -cur.execute("create table test(p)") +cur.execute("CREATE TABLE test(p)") -cur.execute("insert into test(p) values (?)", (p,)) -cur.execute('select p as "p [point]" from test') +cur.execute("INSERT INTO test(p) VALUES (?)", (p,)) +cur.execute('SELECT p AS "p [point]" FROM test') print "with column names:", cur.fetchone()[0] cur.close() con.close() diff -r 8296b686c6de Doc/includes/sqlite3/ctx_manager.py --- a/Doc/includes/sqlite3/ctx_manager.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/ctx_manager.py Thu Nov 01 14:00:45 2012 -0500 @@ -1,16 +1,16 @@ import sqlite3 con = sqlite3.connect(":memory:") -con.execute("create table person (id integer primary key, firstname varchar unique)") +con.execute("CREATE TABLE person (id integer primary key, firstname varchar UNIQUE)") # Successful, con.commit() is called automatically afterwards with con: - con.execute("insert into person(firstname) values (?)", ("Joe",)) + con.execute("INSERT INTO person(firstname) VALUES (?)", ("Joe",)) # con.rollback() is called after the with block finishes with an exception, the # exception is still raised and must be caught try: with con: - con.execute("insert into person(firstname) values (?)", ("Joe",)) + con.execute("INSERT INTO person(firstname) VALUES (?)", ("Joe",)) except sqlite3.IntegrityError: print "couldn't add Joe twice" diff -r 8296b686c6de Doc/includes/sqlite3/execsql_fetchonerow.py --- a/Doc/includes/sqlite3/execsql_fetchonerow.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/execsql_fetchonerow.py Thu Nov 01 14:00:45 2012 -0500 @@ -3,7 +3,7 @@ con = sqlite3.connect("mydb") cur = con.cursor() -SELECT = "select name_last, age from people order by age, name_last" +SELECT = "SELECT name_last, age FROM people ORDER BY age, name_last" # 1. Iterate over the rows available from the cursor, unpacking the # resulting sequences to yield their elements (name_last, age): diff -r 8296b686c6de Doc/includes/sqlite3/execsql_printall_1.py --- a/Doc/includes/sqlite3/execsql_printall_1.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/execsql_printall_1.py Thu Nov 01 14:00:45 2012 -0500 @@ -7,7 +7,7 @@ cur = con.cursor() # Execute the SELECT statement: -cur.execute("select * from people order by age") +cur.execute("SELECT * FROM people ORDER BY age") # Retrieve all rows as a sequence and print that sequence: print cur.fetchall() diff -r 8296b686c6de Doc/includes/sqlite3/execute_1.py --- a/Doc/includes/sqlite3/execute_1.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/execute_1.py Thu Nov 01 14:00:45 2012 -0500 @@ -2,15 +2,15 @@ con = sqlite3.connect(":memory:") cur = con.cursor() -cur.execute("create table people (name_last, age)") +cur.execute("CREATE TABLE people (name_last, age)") who = "Yeltsin" age = 72 # This is the qmark style: -cur.execute("insert into people values (?, ?)", (who, age)) +cur.execute("INSERT INTO people VALUES (?, ?)", (who, age)) # And this is the named style: -cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age}) +cur.execute("SELECT * FROM people WHERE name_last=:who AND age=:age", {"who": who, "age": age}) print cur.fetchone() diff -r 8296b686c6de Doc/includes/sqlite3/execute_3.py --- a/Doc/includes/sqlite3/execute_3.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/execute_3.py Thu Nov 01 14:00:45 2012 -0500 @@ -7,6 +7,6 @@ who = "Yeltsin" age = 72 -cur.execute("select name_last, age from people where name_last=:who and age=:age", +cur.execute("SELECT name_last, age FROM people WHERE name_last=:who AND age=:age", locals()) print cur.fetchone() diff -r 8296b686c6de Doc/includes/sqlite3/executemany_1.py --- a/Doc/includes/sqlite3/executemany_1.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/executemany_1.py Thu Nov 01 14:00:45 2012 -0500 @@ -15,10 +15,10 @@ con = sqlite3.connect(":memory:") cur = con.cursor() -cur.execute("create table characters(c)") +cur.execute("CREATE TABLE characters(c)") theIter = IterChars() -cur.executemany("insert into characters(c) values (?)", theIter) +cur.executemany("INSERT INTO characters(c) VALUES (?)", theIter) -cur.execute("select c from characters") +cur.execute("SELECT c FROM characters") print cur.fetchall() diff -r 8296b686c6de Doc/includes/sqlite3/executemany_2.py --- a/Doc/includes/sqlite3/executemany_2.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/executemany_2.py Thu Nov 01 14:00:45 2012 -0500 @@ -7,9 +7,9 @@ con = sqlite3.connect(":memory:") cur = con.cursor() -cur.execute("create table characters(c)") +cur.execute("CREATE TABLE characters(c)") -cur.executemany("insert into characters(c) values (?)", char_generator()) +cur.executemany("INSERT INTO characters(c) VALUES (?)", char_generator()) -cur.execute("select c from characters") +cur.execute("SELECT c FROM characters") print cur.fetchall() diff -r 8296b686c6de Doc/includes/sqlite3/executescript.py --- a/Doc/includes/sqlite3/executescript.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/executescript.py Thu Nov 01 14:00:45 2012 -0500 @@ -3,20 +3,20 @@ con = sqlite3.connect(":memory:") cur = con.cursor() cur.executescript(""" - create table person( + CREATE TABLE person( firstname, lastname, age ); - create table book( + CREATE TABLE book( title, author, published ); - insert into book(title, author, published) - values ( + INSERT INTO book(title, author, published) + VALUES ( 'Dirk Gently''s Holistic Detective Agency', 'Douglas Adams', 1987 diff -r 8296b686c6de Doc/includes/sqlite3/insert_more_people.py --- a/Doc/includes/sqlite3/insert_more_people.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/insert_more_people.py Thu Nov 01 14:00:45 2012 -0500 @@ -10,7 +10,7 @@ ) for person in newPeople: - cur.execute("insert into people (name_last, age) values (?, ?)", person) + cur.execute("INSERT INTO people (name_last, age) VALUES (?, ?)", person) # The changes will not be saved unless the transaction is committed explicitly: con.commit() diff -r 8296b686c6de Doc/includes/sqlite3/load_extension.py --- a/Doc/includes/sqlite3/load_extension.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/load_extension.py Thu Nov 01 14:00:45 2012 -0500 @@ -6,7 +6,7 @@ con.enable_load_extension(True) # Load the fulltext search extension -con.execute("select load_extension('./fts3.so')") +con.execute("SELECT load_extension('./fts3.so')") # alternatively you can load the extension using an API call: # con.load_extension("./fts3.so") @@ -15,12 +15,12 @@ con.enable_load_extension(False) # example from SQLite wiki -con.execute("create virtual table recipe using fts3(name, ingredients)") +con.execute("CREATE VIRTUAL TABLE recipe USING fts3(name, ingredients)") con.executescript(""" - insert into recipe (name, ingredients) values ('broccoli stew', 'broccoli peppers cheese tomatoes'); - insert into recipe (name, ingredients) values ('pumpkin stew', 'pumpkin onions garlic celery'); - insert into recipe (name, ingredients) values ('broccoli pie', 'broccoli cheese onions flour'); - insert into recipe (name, ingredients) values ('pumpkin pie', 'pumpkin sugar flour butter'); + INSERT INTO recipe (name, ingredients) VALUES ('broccoli stew', 'broccoli peppers cheese tomatoes'); + INSERT INTO recipe (name, ingredients) VALUES ('pumpkin stew', 'pumpkin onions garlic celery'); + INSERT INTO recipe (name, ingredients) VALUES ('broccoli pie', 'broccoli cheese onions flour'); + INSERT INTO recipe (name, ingredients) VALUES ('pumpkin pie', 'pumpkin sugar flour butter'); """) -for row in con.execute("select rowid, name, ingredients from recipe where name match 'pie'"): +for row in con.execute("SELECT rowid, name, ingredients FROM recipe WHERE name MATCH 'pie'"): print row diff -r 8296b686c6de Doc/includes/sqlite3/md5func.py --- a/Doc/includes/sqlite3/md5func.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/md5func.py Thu Nov 01 14:00:45 2012 -0500 @@ -7,5 +7,5 @@ con = sqlite3.connect(":memory:") con.create_function("md5", 1, md5sum) cur = con.cursor() -cur.execute("select md5(?)", ("foo",)) +cur.execute("SELECT md5(?)", ("foo",)) print cur.fetchone()[0] diff -r 8296b686c6de Doc/includes/sqlite3/mysumaggr.py --- a/Doc/includes/sqlite3/mysumaggr.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/mysumaggr.py Thu Nov 01 14:00:45 2012 -0500 @@ -13,8 +13,8 @@ con = sqlite3.connect(":memory:") con.create_aggregate("mysum", 1, MySum) cur = con.cursor() -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") +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] diff -r 8296b686c6de Doc/includes/sqlite3/parse_colnames.py --- a/Doc/includes/sqlite3/parse_colnames.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/parse_colnames.py Thu Nov 01 14:00:45 2012 -0500 @@ -3,6 +3,6 @@ con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) cur = con.cursor() -cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),)) +cur.execute('SELECT ? AS "x [timestamp]"', (datetime.datetime.now(),)) dt = cur.fetchone()[0] print dt, type(dt) diff -r 8296b686c6de Doc/includes/sqlite3/pysqlite_datetime.py --- a/Doc/includes/sqlite3/pysqlite_datetime.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/pysqlite_datetime.py Thu Nov 01 14:00:45 2012 -0500 @@ -3,18 +3,18 @@ con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) cur = con.cursor() -cur.execute("create table test(d date, ts timestamp)") +cur.execute("CREATE TABLE test(d date, ts timestamp)") today = datetime.date.today() now = datetime.datetime.now() -cur.execute("insert into test(d, ts) values (?, ?)", (today, now)) -cur.execute("select d, ts from test") +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]) -cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"') +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]) diff -r 8296b686c6de Doc/includes/sqlite3/row_factory.py --- a/Doc/includes/sqlite3/row_factory.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/row_factory.py Thu Nov 01 14:00:45 2012 -0500 @@ -9,5 +9,5 @@ con = sqlite3.connect(":memory:") con.row_factory = dict_factory cur = con.cursor() -cur.execute("select 1 as a") +cur.execute("SELECT 1 AS a") print cur.fetchone()["a"] diff -r 8296b686c6de Doc/includes/sqlite3/rowclass.py --- a/Doc/includes/sqlite3/rowclass.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/rowclass.py Thu Nov 01 14:00:45 2012 -0500 @@ -4,7 +4,7 @@ con.row_factory = sqlite3.Row cur = con.cursor() -cur.execute("select 'John' as name, 42 as age") +cur.execute("SELECT 'John' AS name, 42 AS age") for row in cur: assert row[0] == row["name"] assert row["name"] == row["nAmE"] diff -r 8296b686c6de Doc/includes/sqlite3/shortcut_methods.py --- a/Doc/includes/sqlite3/shortcut_methods.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/shortcut_methods.py Thu Nov 01 14:00:45 2012 -0500 @@ -8,13 +8,13 @@ con = sqlite3.connect(":memory:") # Create the table -con.execute("create table person(firstname, lastname)") +con.execute("CREATE TABLE person(firstname, lastname)") # Fill the table -con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) +con.executemany("INSERT INTO person(firstname, lastname) VALUES (?, ?)", persons) # Print the table contents -for row in con.execute("select firstname, lastname from person"): +for row in con.execute("SELECT firstname, lastname FROM person"): print row -print "I just deleted", con.execute("delete from person").rowcount, "rows" +print "I just deleted", con.execute("DELETE FROM person").rowcount, "rows" diff -r 8296b686c6de Doc/includes/sqlite3/simple_tableprinter.py --- a/Doc/includes/sqlite3/simple_tableprinter.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/simple_tableprinter.py Thu Nov 01 14:00:45 2012 -0500 @@ -2,7 +2,7 @@ FIELD_MAX_WIDTH = 20 TABLE_NAME = 'people' -SELECT = 'select * from %s order by age, name_last' % TABLE_NAME +SELECT = 'SELECT * FROM %s ORDER BY age, name_last' % TABLE_NAME con = sqlite3.connect("mydb") diff -r 8296b686c6de Doc/includes/sqlite3/text_factory.py --- a/Doc/includes/sqlite3/text_factory.py Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/includes/sqlite3/text_factory.py Thu Nov 01 14:00:45 2012 -0500 @@ -6,13 +6,13 @@ AUSTRIA = u"\xd6sterreich" # by default, rows are returned as Unicode -cur.execute("select ?", (AUSTRIA,)) +cur.execute("SELECT ?", (AUSTRIA,)) row = cur.fetchone() assert row[0] == AUSTRIA # but we can make sqlite3 always return bytestrings ... con.text_factory = str -cur.execute("select ?", (AUSTRIA,)) +cur.execute("SELECT ?", (AUSTRIA,)) row = cur.fetchone() assert type(row[0]) is str # the bytestrings will be encoded in UTF-8, unless you stored garbage in the @@ -23,7 +23,7 @@ # 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" + +cur.execute("SELECT ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) row = cur.fetchone() assert type(row[0]) is unicode @@ -31,10 +31,10 @@ # sqlite3 offers a built-in 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,)) +cur.execute("SELECT ?", (AUSTRIA,)) row = cur.fetchone() assert type(row[0]) is unicode -cur.execute("select ?", ("Germany",)) +cur.execute("SELECT ?", ("Germany",)) row = cur.fetchone() assert type(row[0]) is str diff -r 8296b686c6de Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst Wed Oct 31 20:38:52 2012 +0000 +++ b/Doc/library/sqlite3.rst Thu Nov 01 14:00:45 2012 -0500 @@ -608,11 +608,9 @@ conn = sqlite3.connect(":memory:") c = conn.cursor() - c.execute('''create table stocks - (date text, trans text, symbol text, - qty real, price real)''') - c.execute("""insert into stocks - values ('2006-01-05','BUY','RHAT',100,35.14)""") + c.execute('''CREATE TABLE stocks + (date text, trans text, symbol text, qty real, price real)''') + c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)") conn.commit() c.close() @@ -620,7 +618,7 @@ >>> conn.row_factory = sqlite3.Row >>> c = conn.cursor() - >>> c.execute('select * from stocks') + >>> c.execute('SELECT * FROM stocks') >>> r = c.fetchone() >>> type(r)