[storm] Display executed SQL?

Jamu Kakar jamshed.kakar at canonical.com
Fri Mar 7 17:40:47 GMT 2008


Hi Lutz,

Lutz Horn wrote:
 > is it possible to let Strom display or log the SQL it executes? I'd like
 > to see the SQL to be able to improve the indexes on my tables.

If you're using the released version of Storm, or older, you'll need
to use storm.database.DEBUG trick, as mentioned, to get a dump of
executed queries.  If you want to write data to a different stream
you'll need to hack the code that uses the DEBUG flag (two lines of
code) to use a stream other than sys.stderr.

Storm trunk has a new tracing system which can be used to solve the
same problem (but in a more flexible way):

from storm.tracer import DebugTracer, install_tracer

stream = open(...)
install_tracer(DebugTracer(stream))

If you just want to log to stderr you can use:

from storm.tracer import debug

debug(True) # The flag enables or disables statement logging

There's a branch up [1] for review which adds these details to the
tutorial and makes some minor improvements to the debug helper
function.  Please review it! :)

Thanks,
J.

[1] https://bugs.edge.launchpad.net/storm/+bug/199356



More information about the storm mailing list