2007-08-15 11:28:22 -03:00
|
|
|
import sqlite3
|
2011-04-26 17:55:55 -03:00
|
|
|
import datetime
|
|
|
|
import time
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
def adapt_datetime(ts):
|
|
|
|
return time.mktime(ts.timetuple())
|
|
|
|
|
|
|
|
sqlite3.register_adapter(datetime.datetime, adapt_datetime)
|
|
|
|
|
|
|
|
con = sqlite3.connect(":memory:")
|
|
|
|
cur = con.cursor()
|
|
|
|
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
cur.execute("select ?", (now,))
|
|
|
|
print(cur.fetchone()[0])
|
2019-05-19 18:52:20 -03:00
|
|
|
|
|
|
|
con.close()
|