ยปCore Development>Code coverage>Doc/includes/sqlite3/createdb.py

Python code coverage for Doc/includes/sqlite3/createdb.py

#countcontent
1n/a# Not referenced from the documentation, but builds the database file the other
2n/a# code snippets expect.
3n/a
4n/aimport sqlite3
5n/aimport os
6n/a
7n/aDB_FILE = "mydb"
8n/a
9n/aif os.path.exists(DB_FILE):
10n/a os.remove(DB_FILE)
11n/a
12n/acon = sqlite3.connect(DB_FILE)
13n/acur = con.cursor()
14n/acur.execute("""
15n/a create table people
16n/a (
17n/a name_last varchar(20),
18n/a age integer
19n/a )
20n/a """)
21n/a
22n/acur.execute("insert into people (name_last, age) values ('Yeltsin', 72)")
23n/acur.execute("insert into people (name_last, age) values ('Putin', 51)")
24n/a
25n/acon.commit()
26n/a
27n/acur.close()
28n/acon.close()