TIMESTAMP bug (MySQL >v4.0) with solution
MySQL database connector for Python programming
Brought to you by:
adustman
I had problems loading TIMESTAMP values from my
database and found out that the problem comes from
invalid parsing of the timestamp value. In MySQL
versions 4.1 or higher (perhaps some other versions as
well) the timestamp format has shifted from yyyymmdd
to yyyy-mm-dd.
Here's my solution to the problem. A change to times.py.
It should be incorporated to select the correct parsing
method depending on mysql version used.
in old_mysql_timestamp_converter(s):
...
OLD VERSION
s = s + "0"*(14-len(s)) # padding parts = map(int, filter(None, (s[:4],s[4:6],s[6:8], s[8:10],s[10:12],s[12:14])))
s = s + "0"*(19-len(s)) # padding parts = map(int, filter(None, (s[:4],s[5:7],s[8:10], s[11:13],s[14:16],s[17:19])))
/Simon at Hedberg net
Logged In: YES
user_id=71372
This is already fixed in CVS and the 1.1 series. 1.0 series
does not support MySQL-4.1
Logged In: YES
user_id=71372
Not supporting MySQL-4.1 in MySQLdb-1.0; MySQLdb-1.1 works
with MySQL-4.1.