1 | n/a | import sqlite3 |
---|
2 | n/a | |
---|
3 | n/a | persons = [ |
---|
4 | n/a | ("Hugo", "Boss"), |
---|
5 | n/a | ("Calvin", "Klein") |
---|
6 | n/a | ] |
---|
7 | n/a | |
---|
8 | n/a | con = sqlite3.connect(":memory:") |
---|
9 | n/a | |
---|
10 | n/a | # Create the table |
---|
11 | n/a | con.execute("create table person(firstname, lastname)") |
---|
12 | n/a | |
---|
13 | n/a | # Fill the table |
---|
14 | n/a | con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) |
---|
15 | n/a | |
---|
16 | n/a | # Print the table contents |
---|
17 | n/a | for row in con.execute("select firstname, lastname from person"): |
---|
18 | n/a | print(row) |
---|
19 | n/a | |
---|
20 | n/a | print("I just deleted", con.execute("delete from person").rowcount, "rows") |
---|