source: trunk/essentials/dev-lang/python/Doc/lib/sqlite3/shortcut_methods.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 565 bytes
Line 
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"
Note: See TracBrowser for help on using the repository browser.