#220 incorrect slicing in times.py::mysql_timestamp_converter()

MySQLdb-1.0
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2006-12-05
Michele
No

Using MySQL-python-1.0.0-1.RHEL4.1 from centos 4 I had to modify the code in times.py:

def mysql_timestamp_converter(s):
"""Convert a MySQL TIMESTAMP to a Timestamp object."""
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])))
parts = map(int, filter(None, (s[:4],s[5:7],s[8:10],
s[11:13],s[14:16],s[17:19])))
try: return apply(Timestamp, tuple(parts))
except: return None

to avoid this exception:
File "merge_offline.py", line 71, in ?
importOfflineData('testdump.sql')
File "merge_offline.py", line 47, in importOfflineData
cur.execute(qry)
File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 95, in execute
return self._execute(query, args)
File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 114, in _execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 33, in defaulterrorhandler
raise errorclass, errorvalue
ValueError: invalid literal for int(): 0-

is it somethink known or you just dont care anymore about 1.0 ?

Discussion

  • Andy Dustman
    Andy Dustman
    2006-12-05

    Logged In: YES
    user_id=71372
    Originator: NO

    I really don't care about 1.0, and obviously you are using MySQL-4.1 or newer, which has a different timestamp format. 4.1 and newer are only supported in the 1.2 and newer series.

     
  • Michele
    Michele
    2006-12-05

    Logged In: YES
    user_id=1485401
    Originator: YES

    This has already been fixed in the most recent release; please
    upgrade.

     
  • Michele
    Michele
    2006-12-05

    Logged In: YES
    user_id=1485401
    Originator: YES

    thanks for the answer..I'll forward it to centos and/or RHEL... strange they included a broken library
    Anyway yes it's 4.1.20