On Feb 9, 2011, at 2:58 PM, George V. Reilly wrote: > Under SQLAlchemy 0.5, there used to be some logging setting that would > show the actual SQL queries that were being made. Alas, I forget the > exact invocation. Under SA 0.6, I have not been able to find a way to > do this, short of hacking the SA source. Here's the closest that I've > been able to come > > logging.basicConfig(level=logging.DEBUG) > logging.getLogger('sqlalchemy').setLevel(logging.DEBUG) > logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG) > logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG) > > logging.getLogger('sqlalchemy.dialects.mysql').setLevel(logging.DEBUG) > logging.getLogger('sqlalchemy.orm').setLevel(logging.DEBUG) > logging.getLogger('mysqldb').setLevel(logging.DEBUG) > > but I see no SELECTs in the output. Obviously, this is useful when we > want the server to explain query plans and the like, to understand > performance issues. > > I specifically care about MySQL and SQLite queries.
The above statements are correct. 'sqlalchemy.engine' specifically targets the SQL statements emitted. There is also "echo=True" on create_engine() which is a shortcut for the "sqlalchemy.engine" statement above. A description of logging as applied to SQLAlchemy is at http://www.sqlalchemy.org/docs/core/engines.html#configuring-logging . Note that when using logging, the context of the application may suppress standard output. The test harness "nose" does so unless the -s flag is used, and a daemonizing server like paster server also shuts off standard output. You may need to route the logging to a file instead in a case like the latter. -- 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.