Python - SQLite - List Comprehensions: Database Integrations - function
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(595/682)の解答を求めてみる。
コード
webapp/data_utils.py
import DBcm
import queries
db_details = 'CoachDB.sqlite'
def get_swimmers_events(name, age, dt):
with DBcm.UseDatabase(db_details) as db:
db.execute(
queries.SQL_SWIMMERS_BY_SESSION,
(
name,
age,
dt,
),
)
results = db.fetchall()
return results