Hi Pythonists,

I'm retrieving some time data from a MySQL database using Python's MySQLdb
library. Here's the situation, I got a time field on MySQL given in seconds,
I need it on HH:MM:SS format, so I'm SELECTING that field with SEC_TO_TIME
function, something like this:

query = "SELECT SEC_TO_TIME(SUM(seconds)) FROM table"
fetched = cursor.execute(query)
return fetched[0]

The result of the query is given to me as *datetime.timedelta *type, which
has an undesired print behavior for my purposes:

>>> query = "SELECT SEC_TO_TIME(SUM(seconds)) FROM table"
>>> fetched = cursor.execute(query)
>>> print fetched[0]
3 days, 7:30:09
>>> print type(fetched[0])
<type 'datetime.timedelta'>

Instead of *datetime.timedelta *I need *datetime.time *type. Does anybody
knows how to change this behavior or is it something I must deal with my
code?

Thanks in advanced.

-- 
Jorge Romero
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to