Database query execution times in Python?

Kushal Kumaran kushal.kumaran+python at gmail.com
Sat Aug 8 13:47:50 CEST 2009


On Sat, Aug 8, 2009 at 12:12 AM, pwnedd<keith.hughitt at gmail.com> wrote:
>
> Hi all,
>
> I've been writing some code using libraries based on the Python Database API
> 2.0 (MySQLdb & pg), and so far things are working really well. There is one
> thing that I have not been able to figure out how to do, however:
>
> Retrieve the time is took a given query to execute.
>
> Does anyone know if this is possible?
>

If nothing else, you could always use the time.time() function for
timing sections of code.  This will also include the time it took to
transport the result from the database to your application, though.

-- 
kushal



More information about the Python-list mailing list