Menu

#114 TIMESTAMP bug (MySQL >v4.0) with solution

MySQLdb-1.0
closed
MySQLdb (285)
1
2012-09-19
2004-11-23
Anonymous
No

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])))

NEW VERSION

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

Discussion

  • Andy Dustman

    Andy Dustman - 2004-11-23

    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

     
  • Andy Dustman

    Andy Dustman - 2005-01-23

    Logged In: YES
    user_id=71372

    Not supporting MySQL-4.1 in MySQLdb-1.0; MySQLdb-1.1 works
    with MySQL-4.1.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.