On Mon, 14 Feb 2005 14:44:24 +0100, Anthra Norell
<[EMAIL PROTECTED]> wrote:

>    Since I upgraded to Python 2.4 all my 'select ... date ... from ...'
> commands to MySQL seem to return this format: 
>   
>     "datetime.date ('2005', '01'. '01')" 
>   
> when my routines expect: 
>   
>    "2005-01-01" 

MySQLdb uses the Python built-in datetime when it is available. If you
don't like this:

db = MySQLdb.connect(...)
from MySQLdb.constants import FIELD_TYPE
del db.converter[FIELD_TYPE.DATETIME]
del db.converter[FIELD_TYPE.DATE]
del db.converter[FIELD_TYPE.TIMESTAMP]
del db.converter[FIELD_TYPE.TIME]

There are other variations on how to do this (like deleting the values
from the MySQLdb.converters.conversions, or making a custom
conversions and passing it to connect() via the conv parameter), but
by deleting the converter, you'll get the column as a string.

Or you could update your code. If you are doing any parsing of the
date at all, why not just use the datetime object?

http://docs.python.org/lib/module-datetime.html

-- 
Computer interfaces should never be made of meat.

Using GMail? Setting Reply-to address to <> disables this annoying feature.
_______________________________________________
DB-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to