cpython/Doc/includes/sqlite3/insert_more_langs.py

19 lines
339 B
Python
Raw Normal View History

2007-08-15 14:28:22 +00:00
import sqlite3
con = sqlite3.connect("mydb")
cur = con.cursor()
languages = (
("Smalltalk", 1972),
("Swift", 2014),
)
2007-08-15 14:28:22 +00:00
for lang in languages:
cur.execute("insert into lang (name, first_appeared) values (?, ?)", lang)
2007-08-15 14:28:22 +00:00
# The changes will not be saved unless the transaction is committed explicitly:
con.commit()
con.close()