datetime objects attempt to insert microseconds into MySQL
MySQL database connector for Python programming
Brought to you by:
adustman
The latest CVS version of MySQLdb uses datetime objects
to represent datetime fields in MySQL, which is great.
However when inserting/updating a datetime field, you
currently need to pre-format a python datetime object
to avoid MySQLdb inserting a date like '2004-04-10
15:33:35.4564626', which will work but throw a warning.
Logged In: YES
user_id=71372
How do you feel about doing this in your application:
d.microseconds = 0 # where d is a datetime object
Eventually, MySQL will support fractional timestamps.
Additionally, future versions of MySQLdb (1.1 and up) will
use the warnings module handle warnings, so this should be
less of an issue.
Logged In: YES
user_id=71372
Oops, it's microsecond, and it's read-only.
Maybe you could set the microseconds to 0 when you create it?
Reset status to Open if you reply; otherwise I will probably
not see it.
Logged In: YES
user_id=71372
This has been fixed in the current CVS tree.
Logged In: YES
user_id=294560
The only reason I could see for wanting the driver to trim
off the microseconds is that frees up the coder to use
methods like datetime.today(), which help in readability.
Beside the point now though, thank you for addressing this
in the code =).