Created
February 25, 2013 05:46
-
-
Save c0ldlimit/5028006 to your computer and use it in GitHub Desktop.
#sqlite3 #python returning datetime from sqlite in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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