diff options
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() |