summaryrefslogtreecommitdiffstats
path: root/Doc/includes/sqlite3/execute_1.py
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/includes/sqlite3/execute_1.py')
-rw-r--r--Doc/includes/sqlite3/execute_1.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Doc/includes/sqlite3/execute_1.py b/Doc/includes/sqlite3/execute_1.py
index 3d08840..f864a89 100644
--- a/Doc/includes/sqlite3/execute_1.py
+++ b/Doc/includes/sqlite3/execute_1.py
@@ -1,11 +1,16 @@
import sqlite3
-con = sqlite3.connect("mydb")
-
+con = sqlite3.connect(":memory:")
cur = con.cursor()
+cur.execute("create table people (name_last, age)")
who = "Yeltsin"
age = 72
-cur.execute("select name_last, age from people where name_last=? and age=?", (who, age))
+# This is the qmark style:
+cur.execute("insert into people values (?, ?)", (who, age))
+
+# And this is the named style:
+cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age})
+
print(cur.fetchone())