When storing a time in Python (in my case in ZODB, but applies to any DB), what format (epoch, datetime etc) do you use and why?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The datetime module has the standard types for modern Python handling of dates and times, and I use it because I like standards (I also think it’s well designed); I typically also have timezone information via pytz.
Most DBs have their own standard way of storing dates and times, of course, but modern Python adapters to/from the DBs typically support
datetime(another good reason to use it;-) on the Python side of things — for example that’s what I get with Google App Engine’s storage, Python’s own embedded SQLite, and so on.