diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-05-19 07:41:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 07:41:19 (GMT) |
commit | 92d1064727d6b7f4136f9c09ab52ae15e3676afe (patch) | |
tree | ae8bf88ce5406adf0d8fc2f0f64f8b20de077142 /Doc/includes/sqlite3/execsql_fetchonerow.py | |
parent | 901443757333a66ff2b5c85eba30dc1c48eac321 (diff) | |
download | cpython-92d1064727d6b7f4136f9c09ab52ae15e3676afe.zip cpython-92d1064727d6b7f4136f9c09ab52ae15e3676afe.tar.gz cpython-92d1064727d6b7f4136f9c09ab52ae15e3676afe.tar.bz2 |
bpo-44106: Improve sqlite3 example database contents (GH-26027)
Diffstat (limited to 'Doc/includes/sqlite3/execsql_fetchonerow.py')
-rw-r--r-- | Doc/includes/sqlite3/execsql_fetchonerow.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/includes/sqlite3/execsql_fetchonerow.py b/Doc/includes/sqlite3/execsql_fetchonerow.py index 115bcb5..0ca7e14 100644 --- a/Doc/includes/sqlite3/execsql_fetchonerow.py +++ b/Doc/includes/sqlite3/execsql_fetchonerow.py @@ -3,17 +3,17 @@ import sqlite3 con = sqlite3.connect("mydb") cur = con.cursor() -SELECT = "select name_last, age from people order by age, name_last" +SELECT = "select name, first_appeared from people order by first_appeared, name" # 1. Iterate over the rows available from the cursor, unpacking the -# resulting sequences to yield their elements (name_last, age): +# resulting sequences to yield their elements (name, first_appeared): cur.execute(SELECT) -for (name_last, age) in cur: - print('%s is %d years old.' % (name_last, age)) +for name, first_appeared in cur: + print(f"The {name} programming language appeared in {first_appeared}.") # 2. Equivalently: cur.execute(SELECT) for row in cur: - print('%s is %d years old.' % (row[0], row[1])) + print(f"The {row[0]} programming language appeared in {row[1]}.") con.close() |