Reputation: 1081
i need the alembic syntax for an operation like
select id from table1 where id not in (select id from table2)
there doesn't seem to be any documentation anywhere on this. any pointers would be helpful
Upvotes: 0
Views: 494
Reputation: 127250
To execute raw SQL queries, use op.get_bind()
to get a Connection, then use it's execute
method.
c = op.get_bind()
result = c.execute('select id from table1 where id not in (select id from table2)')
If you are only performing update
and delete
and don't need results, you can use op.execute
as a shortcut.
op.execute('delete from table2 where id in (select id from table1)')
Upvotes: 1