On Sat, Apr 13, 2019 at 4:56 AM Markus Elfring <[email protected]> wrote: > > Hello, > > I would like to count value combinations in database records together with > the software “SQLAlchemy 1.3.2”. > The computation result should be stored into a dynamically generated table. > > I have found a few answers for this data processing task. > > How to create a new table from select statement in sqlalchemy? > creating a temporary table from a query using sqlalchemy orm > > > I am curious also how such table creation can be achieved by the programming > interface “Object Relational Mapper” currently.
both of the above stackoverflow recipes refer to usage of the SQLAlchemy select() object. When you have an ORM Query object, you can get the underlying select() from it by calling upon the .statement accessor: my_query = session.query(Entity).filter_by(foo='bar') ins = InsertFromSelect(temp, my_query.statement) session.execute(ins) https://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=query%20statement#sqlalchemy.orm.query.Query.statement > > Regards, > Markus > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
