Python code coverage for Doc/includes/sqlite3/execute_1.py
# | count | content |
---|---|---|
1 | n/a | import sqlite3 |
2 | n/a | |
3 | n/a | con = sqlite3.connect(":memory:") |
4 | n/a | cur = con.cursor() |
5 | n/a | cur.execute("create table people (name_last, age)") |
6 | n/a | |
7 | n/a | who = "Yeltsin" |
8 | n/a | age = 72 |
9 | n/a | |
10 | n/a | # This is the qmark style: |
11 | n/a | cur.execute("insert into people values (?, ?)", (who, age)) |
12 | n/a | |
13 | n/a | # And this is the named style: |
14 | n/a | cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age}) |
15 | n/a | |
16 | n/a | print(cur.fetchone()) |