PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Doc/includes/sqlite3/shortcut_methods.py

http://unladen-swallow.googlecode.com/
Python | 21 lines | 11 code | 6 blank | 4 comment | 2 complexity | 4dc077c8efa7882fa8a82ba8c463c9b1 MD5 | raw file
 1import sqlite3
 2
 3persons = [
 4    ("Hugo", "Boss"),
 5    ("Calvin", "Klein")
 6    ]
 7
 8con = sqlite3.connect(":memory:")
 9
10# Create the table
11con.execute("create table person(firstname, lastname)")
12
13# Fill the table
14con.executemany("insert into person(firstname, lastname) values (?, ?)", persons)
15
16# Print the table contents
17for row in con.execute("select firstname, lastname from person"):
18    print row
19
20# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.
21print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows"