In SQLAlchemy, how do I populate or update a table from a SELECT
statement?
views:
166answers:
1
+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
2009-12-04 20:30:27
Would you suggest session.execute('INSERT INTO t1 (%s)' % str(sqlalchemy_select_expression))?
joeforker
2009-12-04 20:35:40
Sure, why not - don't need the `str()` though, since `%s` already does that.
nosklo
2009-12-05 14:00:35