Insert into () SELECT & SELECT INTO
A simple and nice feature to have is a way to construct SQL expressions for Insert into SELECT and SELECT INTO Statements.
The interface would be as simple as:
insert(<selectable>)
I don't imagine it would be that hard to do, mostly since I already did it, by extracting the selectable's text:
sql = "INSERT INTO %(table)s %(columns)s %(select_stmt)" % (<table>, <columns>, str(<selectable>) % <selectable>.compile().get_params() )
conn.execute(sql)
However, this seems "wrong" - in many ways. Hence I'd like to be able to simply say:
conn.execute(insert(<selectable>))
For a select into statement, probably a select() keyword like:
select(<columns>,<where>,into_table=<new_table_name>)
Comments (4)
-
Account Deleted -
repo owner - changed milestone to 0.6.xx
its sort of a "blue sky" for me but is a pretty common expression construct so putting in on the 0.6 track for now.
-
repo owner INSERT .. SELECT should suffice here.
-
repo owner - removed milestone
Removing milestone: 0.8.xx (automated comment)
- Log in to comment
Along these lines being able to generate a CREATE TABLE ... AS select-statement clause with:
would be very nice.