insert.from_select() will accept the Query object directly. if using
the CreateTableAs recipe, it can be modified to coerce a Query passed
to it into a Core statement internally. the code to do this coercion
would resemble:
def __init__(self, name, query):
if isinstance(query, orm.Query):
query = query.statement
self.name = name
self.query = query
On Mon, Apr 15, 2019 at 8:43 AM Markus Elfring <[email protected]> wrote:
>>
>> 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:
>
>
> Thanks for this information.
>
> I imagine that there is no need to use the attribute “statement” if I can
> stick to the high-level ORM programming interface.
>
>
>>
>> ins = InsertFromSelect(temp, my_query.statement)
>> session.execute(ins)
>
>
> The call of the method “Insert.from_select” can occasionally be also
> interesting.
> But I am looking for direct support of the SQL command “CREATE TABLE AS
> SELECT” (CTAS) without switching to the “core” API.
> Will any software extensions be helpful for this purpose?
>
> 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.