[Tutor] MySQLdb table is DATE, but SELECT returns with
TIMESTAMP.
Magnus Lyckå
magnus@thinkware.se
Wed Jun 18 03:58:07 2003
You won't understand this by reading MySQL manuals, you
must understand what data types you use in *Python*.
I assume that you use mx.DateTime.DateTime in Python for
date handling. This is the type returned from a call to
the mx.DateTime.Date function, which I assume the MySQLdb
layer performs when you select a date from the database.
This is no text string, it's a DateTime object. mx.DateTime
uses the same type for timestamps and dates, just setting the
time part to midnight in simple dates.
Example:
>>> import mx.DateTime
>>> d = mx.DateTime.Date(2003,1,4)
>>> print d
2003-01-04 00:00:00.00
If you want to erase all rows in table T where column C is a
Date with value 2003-11-11 00:00:00.00, you would do something
like:
cur.execute('DELETE FROM T WHERE C = %s',(mx.DateTime.Date(2003,11,11),))
--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language