Roundtrip SQL data especially datetime

dyork reverseyorkage at david.com
Fri Dec 15 05:44:33 EST 2006


When getting data from a database using the dbapi and an SQL query, how do 
you in general round trip the data? Especially date-time?



An SQL datetime column translates nicely into a Python datetime (surprise), 
which then translates into a string like '2005-08-03 07:32:48'. No problem 
with that -- all works quite nicely, until you try to put data back the 
other way.



There is no obvious way to parse that string back into a datetime, and 
having done so no obvious way to push that back into a SQL datetime column. 
Am I missing something?



[I would particularly like to avoid getting trapped by SQL "local settings" 
too.]



DavidY





More information about the Python-list mailing list