Database Timestamp conversion error

kyosohma at gmail.com kyosohma at gmail.com
Fri Apr 6 16:48:47 EDT 2007


Hi,

 I am populating a mySQL database with data from the MS Access
database. I have successfully figured out how to extract the data from
Access, and I can insert the data successfully into mySQL with Python.
My problem is that I keep hitting screwy records with what appears to
be a malformed dbiDate object when I insert certain records. I get the
following traceback:

Traceback (most recent call last):
  File "\\someServer\Development\collectiveFleet.py", line 68, in -
toplevel-
    mycursor.execute(sql)
TypeError: argument 1 must be string without null bytes, not str

When I print the timestamp variable, I get this output:

(I31
(S'OK'
p1
Nttp2
.

If I look in the MS Access database, I see the timestamp as "5/6/112".
Obviously some user didn't enter the correct date and the programmer
before me didn't give Access strict enough rules to block bad dates.
How do I test for a malformed date object so I can avoid this? There
are thousands of records to transfer.

I am using the odbc module for connection purposes with Python 2.4 on
Windows XP SP2.

Thanks a lot!

Mike




More information about the Python-list mailing list