1import sqlite3 2 3langs = [ 4 ("C++", 1985), 5 ("Objective-C", 1984), 6] 7 8con = sqlite3.connect(":memory:") 9 10# Create the table 11con.execute("create table lang(name, first_appeared)") 12 13# Fill the table 14con.executemany("insert into lang(name, first_appeared) values (?, ?)", langs) 15 16# Print the table contents 17for row in con.execute("select name, first_appeared from lang"): 18 print(row) 19 20print("I just deleted", con.execute("delete from lang").rowcount, "rows") 21 22# close is not a shortcut method and it's not called automatically, 23# so the connection object should be closed manually 24con.close() 25