1import sqlite3 2import datetime 3import time 4 5def adapt_datetime(ts): 6 return time.mktime(ts.timetuple()) 7 8sqlite3.register_adapter(datetime.datetime, adapt_datetime) 9 10con = sqlite3.connect(":memory:") 11cur = con.cursor() 12 13now = datetime.datetime.now() 14cur.execute("select ?", (now,)) 15print(cur.fetchone()[0]) 16