If DateTime is available, MySQLdb returns a DateTime object for each Date field in the requested query.
Although DateTime objects are incredibly powerful, I'm just looking for the date as a string and am forced to convert the string after it's returned from the database or using the FORMAT function in my SQL query.
Both ideas will work, but it would be nice to be able to turn off the use of DateTime in the MySQLdb module as needed. It didn't appear to be possible from looking at the CVS source without directly changing things in MySQLdb.py. Would it be possible to add this ability?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Python 2.0
MySQLdb 0.3.5
If DateTime is available, MySQLdb returns a DateTime object for each Date field in the requested query.
Although DateTime objects are incredibly powerful, I'm just looking for the date as a string and am forced to convert the string after it's returned from the database or using the FORMAT function in my SQL query.
Both ideas will work, but it would be nice to be able to turn off the use of DateTime in the MySQLdb module as needed. It didn't appear to be possible from looking at the CVS source without directly changing things in MySQLdb.py. Would it be possible to add this ability?
Two options:
1) don't install mx.DateTime.
2) Make your own version of MySQLdb.quote_conv, sans DateTime convertors, and pass this to connect(), i.e.
my_type_conv = MySQLdb.type_conv.copy()
del my_type_conv[MySQLdb.FIELD_TYPE.DATE]
db = MySQLdb.connect(...,conv=my_type_conv)
Note that column types not present in type_conv are converted to strings.
"2) Make your own version of MySQLdb.quote_conv, sans DateTime convertors, and pass this to connect(), i.e."
Thanks a bunch. That's exactly what I was looking for.