python-by-example-150-chall.../challenges139-145/challenge-143_.py

15 lines
353 B
Python
Raw Normal View History

2021-12-08 19:19:52 +08:00
import sqlite3
with sqlite3.connect("BookInfo.db") as db:
cursor=db.cursor()
selectionyear=int(input("Enter a year: "))
print()
cursor.execute("""SELECT Books.Title, Books.DatePublished, Books.Author
FROM Books WHERE DatePublished >? ORDER BY DatePublished""", [selectionyear])
for x in cursor.fetchall():
print(x)
db.close()