Skip to content

Instantly share code, notes, and snippets.

@c0ldlimit
Created February 25, 2013 05:46
Show Gist options
  • Select an option

  • Save c0ldlimit/5028006 to your computer and use it in GitHub Desktop.

Select an option

Save c0ldlimit/5028006 to your computer and use it in GitHub Desktop.
#sqlite3 #python returning datetime from sqlite in Python
# http://stackoverflow.com/questions/1829872/read-datetime-back-from-sqlite-as-a-datetime-in-python
db = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES)
c = db.cursor()
c.execute('create table foo (bar integer, baz timestamp)')
c.execute('insert into foo values(?, ?)', (23, datetime.datetime.now()))
c.execute('select * from foo')
c.fetchall()
[(23, datetime.datetime(2009, 12, 1, 19, 31, 1, 40113))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment