Event: do_orm_execute inserted value

29 views
Skip to first unread message

Tomas Pavlovsky

unread,
Sep 20, 2023, 8:37:15 AM9/20/23
to sqlalchemy
Hi Mike,

how to access inserted value in do_orm_execute?
Event "before_insert" has "target" parameter, but how to do it in do_orm_execute?
session.execute(insert(User).values(name="name"))
I need to access name value but don't know how?
Thanks


Mike Bayer

unread,
Sep 20, 2023, 9:54:42 AM9/20/23
to noreply-spamdigest via sqlalchemy
for a statement like that where the values are embedded in the insert() construct directly you would use:

     orm_execute_state.statement.compile().params


otherwise if parameters are sent separately, they are in orm_execute_state.parameters
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
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+...@googlegroups.com.

Tomas Pavlovsky

unread,
Sep 20, 2023, 10:57:37 AM9/20/23
to sqlalchemy
Thank you.
Reply all
Reply to author
Forward
0 new messages