Python - SQLite - List Comprehensions: Database Integrations - select
Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly Guide、 Paul Barry(著)、 O’Reilly Mediaの Chapter 13.(List Comprehensions: Database Integrations)、EXERCISE(589/682)の解答を求めてみる。
Jupyter(コード、入出力結果)
TryQueries.ipynb
import DBcm
db_details = 'CoachDB.sqlite3'
from queries import SQL_SESSION
print(SQL_SESSION)
select distinct ts from times
with DBcm.UseDatabase(db_details) as db:
db.execute(SQL_SESSION)
results = db.fetchall()
results
[('2025-08-25 05:33:42',)]