views:

166

answers:

1

In SQLAlchemy, how do I populate or update a table from a SELECT statement?

+1  A: 

SQLalchemy doesn't build this construct for you. You can use the query from text.

session.execute('INSERT INTO t1 (SELECT * FROM t2)')
nosklo
Would you suggest session.execute('INSERT INTO t1 (%s)' % str(sqlalchemy_select_expression))?
joeforker
Sure, why not - don't need the `str()` though, since `%s` already does that.
nosklo