How to create table from select statements in sqlalchemy

838 views
Skip to first unread message

Ranjith Ramachandra

unread,
Jun 1, 2015, 9:39:13 AM6/1/15
to sqlal...@googlegroups.com
I am using sqlalchemy's core features do write some abstraction layer. The layer itself needs to be able to create tables from select statements.

Sample code:

    metadata = MetaData(bind=engine)
    table = Table(table_name, metadata, autoload=True, autoload_with=engine)
    s = select(table).where(table.c.column_1 > 10)

Now what I want to be able to is create a new table from the select statement above. How can I do it?


Ranjith Ramachandra

unread,
Jun 1, 2015, 9:40:38 AM6/1/15
to sqlal...@googlegroups.com

Mike Bayer

unread,
Jun 1, 2015, 11:18:09 AM6/1/15
to sqlal...@googlegroups.com
can you be more specific?  What DDL would you like to emit ?






--
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.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Ranjith

unread,
Jun 1, 2015, 11:20:24 AM6/1/15
to sqlal...@googlegroups.com
I would like create table as select statement


--
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/lKDkX68fOqI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.

Mike Bayer

unread,
Jun 1, 2015, 11:44:31 AM6/1/15
to sqlal...@googlegroups.com


On 6/1/15 11:19 AM, Ranjith wrote:
I would like create table as select statement


OK but also you want to use bound parameters, apparently.  I've answered the question at http://stackoverflow.com/a/30577608/34549.
Reply all
Reply to author
Forward
0 new messages