Thanks Simon. Your answers always help immensely getting to know SA better. I now know the overview.
On Tue, Jul 25, 2017 at 1:45 AM, Simon King <si...@simonking.org.uk> wrote: > On Tue, Jul 25, 2017 at 2:35 AM, Jinghui Niu <niujing...@gmail.com> wrote: > > I was wondering if there is a way to configure Session.commit() so on > each > > successful commit, it will return the committed/updated/deleted > instance's > > class.__name__ + row.id. Is this possible? Thanks. > > No, there's no way to make the commit() method do that. In general the > request doesn't really make sense as a commit may cover multiple > instances, not just one. Also, objects are inserted/updated during a > flush(), which may happen separately from the commit(). > > If you wanted to build this yourself, you could use ORM events > (http://docs.sqlalchemy.org/en/latest/orm/events.html) to be notifed > when an instance is inserted/updated/deleted. > > Hope that helps, > > Simon > > -- > 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 a topic in the > Google Groups "sqlalchemy" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/sqlalchemy/B8zpOVkCzv4/unsubscribe. > To unsubscribe from this group and all its topics, 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.