the Project model is actually in there, but not in a public API place (this is not the solution, but look inside of table._annotations to see it).
The closest public API we have for this very new API right now is the Query equivalent of column_descriptions, which is available on the select() construct and works when the thing being selected is ORM-enabled, and, alarmingly, it seems there is no documentation whatsoever for the Select version of it, that is wrong, but anyway see the 1.x docs for now: https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Query.column_descriptions This accessor would ideally be on insert, update and delete also, which it currently is not. However, here's a quick way to get it right now: class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) data = Column(String) upd = update(A) print(select(upd.table).column_descriptions) i might take a crack at cleaning this up now but the above will get you what you need. On Sat, Mar 26, 2022, at 1:34 PM, mkmo...@gmail.com wrote: > Hello, > > How can I infer the ORM model class from an update (or insert, or delete) > function result? > > upd = update(Project).values(name='foo').where( > Project.id == 1 > ) > > def my_library_function(session, upd): > result = session.execute(upd) > # how to get the Project ORM model here, using only session and upd ? > > I saw that the update() object has a `table` attribute, but this returns the > Core table (not the ORM model). In addition I don't have access to the > base/registry from this function (unless it can be derived from session?). > Moreover it seems like searching the registry is O(n) and will not work in > all cases, such as when two ORM models map to the same Core table. > > Thanks and best regards, > > Matthew > > > > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/9fc63126-a36d-4e36-b4df-50701bfcae47n%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/9fc63126-a36d-4e36-b4df-50701bfcae47n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/93ec73f0-5bf0-4901-9150-c2d96a19de1c%40www.fastmail.com.