diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-05-19 09:41:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 10:41:19 +0300 |
commit | 92d1064727d6b7f4136f9c09ab52ae15e3676afe (patch) | |
tree | ae8bf88ce5406adf0d8fc2f0f64f8b20de077142 /Doc/includes/sqlite3/execute_1.py | |
parent | 901443757333a66ff2b5c85eba30dc1c48eac321 (diff) | |
download | cpython-92d1064727d6b7f4136f9c09ab52ae15e3676afe.tar.gz cpython-92d1064727d6b7f4136f9c09ab52ae15e3676afe.zip |
bpo-44106: Improve sqlite3 example database contents (GH-26027)
Diffstat (limited to 'Doc/includes/sqlite3/execute_1.py')
-rw-r--r-- | Doc/includes/sqlite3/execute_1.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Doc/includes/sqlite3/execute_1.py b/Doc/includes/sqlite3/execute_1.py index 42aad4d5839..ee0000e2b94 100644 --- a/Doc/includes/sqlite3/execute_1.py +++ b/Doc/includes/sqlite3/execute_1.py @@ -2,22 +2,21 @@ import sqlite3 con = sqlite3.connect(":memory:") cur = con.cursor() -cur.execute("create table lang (lang_name, lang_age)") +cur.execute("create table lang (name, first_appeared)") # This is the qmark style: -cur.execute("insert into lang values (?, ?)", ("C", 49)) +cur.execute("insert into lang values (?, ?)", ("C", 1972)) # The qmark style used with executemany(): lang_list = [ - ("Fortran", 64), - ("Python", 30), - ("Go", 11), + ("Fortran", 1957), + ("Python", 1991), + ("Go", 2009), ] cur.executemany("insert into lang values (?, ?)", lang_list) # And this is the named style: -cur.execute("select * from lang where lang_name=:name and lang_age=:age", - {"name": "C", "age": 49}) +cur.execute("select * from lang where first_appeared=:year", {"year": 1972}) print(cur.fetchall()) con.close() |