Python - MySQL fetching values

Kurian Thayil kurianmthayil at gmail.com
Thu May 6 04:47:40 EDT 2010


Hi All,

I am pretty new to python, and I have an issue with fetching values in
python using MySQLdb module. The query executed is
*SELECT TIME(DATE_ADD(info_last_calltime, INTERVAL %s MINUTE)) FROM
rem_call_info WHERE info_ctrlid=%s""", (retryinterval,controlid1,)*

where retryinterval=30 and controlid=2, the expected output is *05:35:05*.

Now, here is code snippet,

                cursor1=getconnect1.cursor()
                getrows=cursor1.execute("""SELECT
TIME(DATE_ADD(info_last_calltime, INTERVAL %s MINUTE)) FROM rem_call_info
WHERE info_ctrlid=%s""", (retryinterval,controlid1,))
                rawstatus20result=cursor1.fetchone()
                print "Raw result is",rawstatus20result
                status20result=rawstatus20result[0]
                print "The query result for Status
20:",status20result,";Time now is",timeformat

The output is:

Raw result is (datetime.timedelta(0, 20105),)
The query result for Status 20: 5:35:05 ;Time now is 05:22:00
Match not found.
New call to be made
Getting next value if any...

If you look closer, the time fetched by python module was 5:35:05 instead of
05:35:05. How can I get this time format? Thanks in advance.

Regards,

Kurian Thayil.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100506/eb9c39e3/attachment.html>


More information about the Python-list mailing list