Maja Piechotka
Maja Piechotka

Reputation: 7216

Logging queries with sqlalchemy 0.6

With turbogears 2.1 and sqlalchemy 0.7 the queries from console were logged out to stdout. However I needed to downgred to 0.6 and they no longer appear. Documentation of logging seems to be identical and I couldn't find anything in changelog. How to log in sqlalchemy 0.6?

EDIT The DBSession.bind.echo is set to False. If I set it to True it works. Any idea how to set it correctly (I'v modified model/__init__.py setting engine.echo = True).

Upvotes: 3

Views: 1447

Answers (2)

amol
amol

Reputation: 1791

Your configuration file should have the specified options. Look for those inside the development.ini

sqlalchemy.echo = true
sqlalchemy.echo_pool = true

Upvotes: 3

Vinay Sajip
Vinay Sajip

Reputation: 99317

I don't know about TurboGears, but you need to ensure that the engine's echo setting is set to True, e.g.

engine = sqlalchemy.create_engine('sqlite:///:memory:', echo=True)

By default, the echo setting is False, so queries aren't logged to stdout. It's possible that TG configures the two SA versions differently.

Upvotes: 5

Related Questions