On Thu, Mar 15, 2018 at 8:25 AM, Uri Okrent <uokr...@gmail.com> wrote:
> Hey all, are there any more knobs to turn besides the logging debug level
> ("DEBUG", "INFO")?  Specifically I would like to somehow be able to log
> read-only queries to a separate log (or maybe even skip logging those
> altogether) since they are far more numerous and frequent.

use execution events for this, before_cursor_execute tends to be a
good choice (but not the only one):

http://docs.sqlalchemy.org/en/latest/core/events.html?highlight=before_cursor_execute#sqlalchemy.events.ConnectionEvents.before_cursor_execute

within the event, take a look at the context to see what kind of query
it is (or just inspect the string SQL itself).  context has
"context.compiled.statement", "context.isinsert", "context.isupdate",
"context.is_crud", "context.isddl" (clearly I'll have to make the
names more consistent someday) etc.





>
> Thanks
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to