On Jan 27, 2011, at 8:12 PM, NiL wrote:

> Hi all,
> 
> I have an application replying on sqlalchemy that deals with many
> recursive methods. We manipulate complex graphs.
> 
> I have tests that validates we get the expected results for each
> method.
> Still, many optimization might be done to the code.
> 
> What I would like is, in my test environment, evaluate the number of
> queries to the database. I'm aware that the debug mode will output
> every generated SQL, but I deal with a number of queries in the 100s
> range ...
> 
> Is there a way to know how many SQL statement have been executed, from
> the python testing code ?

you use a ConnectionProxy for this (will be the "execute" event in 0.7).  This 
example uses a timer, you'd adapt this idea to instead issue a count.   You can 
use threadlocal variables or similar to pull out/reset the count of statements 
after an execution:

http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Profiling

> 
> Regards
> NiL
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to