如何删除所有表,包括依赖对象

时间:2020-02-13 11:40:48

标签: python postgresql sqlalchemy psycopg2

当我尝试使用以下方法删除所有表时:

base.metadata.drop_all(engine)

我遇到以下错误:

ERROR:libdl.database_operations:Cannot drop table: (psycopg2.errors.DependentObjectsStillExist) cannot drop sequence <schema>.<sequence> because other objects depend on it
DETAIL:  default for table <schema>.<table> column id depends on sequence <schema>.<sequence>
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

是否有一种优雅的单线解决方案?

1 个答案:

答案 0 :(得分:0)

-O3
相关问题