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