我需要使用alembic语法进行类似
的操作select id from table1 where id not in (select id from table2)
此处似乎没有任何文档。任何指针都会有所帮助
答案 0 :(得分:1)
要执行原始SQL查询,请使用op.get_bind()
获取Connection,然后使用execute
方法。
c = op.get_bind()
result = c.execute('select id from table1 where id not in (select id from table2)')
如果您仅执行update
和delete
并且不需要结果,则可以使用op.execute
作为捷径。
op.execute('delete from table2 where id in (select id from table1)')