Hi *,

just figured that other people may be running into the same problem.

I just finally got my sqlalchemy engine to accept a new log level at
runtime. I followed the documentation and passed "echo=False" when
creating the engine.

Beforehand I had configured logging by

import logging
logging.basicConfig(logging.DEBUG)
logging.getLogger("sqlalchemy.engine").setLevel(logging.DEBUG)

But echo=False is not the default as stated in the create_engine
documentation at 

http://www.sqlalchemy.org/docs/06/core/engines.html?highlight=create_engine#sqlalchemy.create_engine

At commit 1adbbfddc979 in rel_0_6, the default in fact comes from
sqlalchemy/lib/sqlalchemy/engine/base.py class Engine:

    def __init__(self, pool, dialect, url,
                        logging_name=None, echo=None, proxy=None,
                        execution_options=None
                        ):

which triggers this code in log.py:

    if echoflag is not None:
        l = logging.getLogger(name)
        ...
        elif echoflag is False:
            l.setLevel(logging.WARN)
    else:
        l = logging.getLogger(name)

So this overwrites the log level I had set via logger.setLevel. This
seems to be fixed in 0.7 (where False and None are equivalent according
to a short glance).

So this will not give any output:

import logging
from sqlalchemy import *

logging.basicConfig(level=logging.DEBUG)
logging.getLogger("sqlalchemy.engine").setLevel(logging.DEBUG)

engine = create_engine("sqlite:///", echo=False)
engine.execute("select 1")

Changing "echo=False" in the create_engine call to "echo=None" (or
removing echo=False altogether) will fix this. Uargh!

Greetings, Torsten

PS: Just checked, in SQLAlchemy 0.7.3 there is no difference between
passing "echo=None" and "echo=False".

-- 
DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
Torsten Landschoff

Office Dresden
Tel: +49-(0)351-4519587
Fax: +49-(0)351-4519561

mailto:[email protected]
http://www.dynamore.de

Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
Managing director:  Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz

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

Reply via email to