On Thursday, March 15, 2018 at 9:11:06 AM UTC-4, Mike Bayer wrote:

> 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


thanks this looks like what I was looking for. 
 

> 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. 
>

The ExecutionContext docs linked from there 
(http://docs.sqlalchemy.org/en/latest/core/internals.html#sqlalchemy.engine.interfaces.ExecutionContext)
 
lists 'isinsert', and 'isupdate', however I don't see 'is_crud' or 
'isddl'.  Are these last two internals or are they public and just haven't 
been documented? I assume that is_crud includes both isinsert and 
isupdate?  Is this determination being made at the sqlalchemy core 
abstraction layer level, or on the generated statement itself?  For 
example, will isinsert be true for something like this: 
`session.execute(text("""INSERT..."""))`?

thanks again

-- 
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