DatetimeUsageGuide

Not logged in - Log In / Register

Revision 1 as of 2009-01-12 19:53:39

Clear message

Database Transaction Time

Storing the current database transaction time in the database use the following syntax:

(note that you won't be able to read the value as a Python datetime object until the sync() method for the SQLObject is called, or the transaction is committed).

To store a time relative to the present time in a database column, we can make use of the fact that UTC_NOW is an "sql builder" type:

The database transaction time can be retrieved like so:

Present Time

To create a Python datetime object that represents the present time, use the following code:

Note that the datetime.utcnow() method should not be used -- it creates a naïve datetime value, which can not be compared against other values in Launchpad.