'test plain returns' noise when setting echo=True

Issue #3026 wontfix
Christopher Monsanto created an issue

When using the pysqlite dialect, setting echo=True will print

2014-04-17 14:25:25,950 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2014-04-17 14:25:25,950 INFO sqlalchemy.engine.base.Engine ()
2014-04-17 14:25:25,950 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2014-04-17 14:25:25,950 INFO sqlalchemy.engine.base.Engine ()

when executing the first query. There appears to be no way to tell DefaultDialect not to run these tests--it ignores any existing value of returns_unicode_strings.

Why this is a problem: I have a script that connects, runs a query, and disconnects. This script is run at a regular interval. When debugging this script, the cast tests take up 2/3s of the log.

Comments (3)

  1. Mike Bayer repo owner

    the test isn't needed on sqlite actually as we know what pysqlite does, but there's any number of queries that any dialect might be running on first connect, like queries to get the current schema, current user, etc. So this is not really about the unicode test, it's about the bigger pattern of tests that might run and as of more recent versions are now logged, IMHO as they should be.

    I don't have any "fix" for this at the moment, while these queries were excluded from logging in past releases the system has been consolidated and IMHO is better designed that everything goes through the same pipe.

    one workaround would be just this:

    e = create_engine("sqlite://..")
    e.connect().close()
    e.echo = True
    

    another, maybe more appropriate, is that since your situation calls for logging that is "special", e.g. you want only specific things logged, implement your own logging using a cursor_execute() event, see http://docs.sqlalchemy.org/en/rel_0_9/core/events.html?highlight=before_cursor_execute#sqlalchemy.events.ConnectionEvents.before_cursor_execute.

  2. Log in to comment