Python 不顾外键约束复制表

Python 不顾外键约束复制表,python,postgresql,psycopg2,Python,Postgresql,Psycopg2,我正在尝试创建一个报告数据库,每隔几个小时左右从生产数据库更新一次。我正在使用python脚本和psycopg2来实现这一点。我可以使用以下代码复制一些表: speedy_serve_cursor = speedy_serve_con.cursor() archives_cursor = archives_con.cursor() speedy_serve_cursor.execute('SELECT * from "TranslatableItems"') for row in speed

我正在尝试创建一个报告数据库,每隔几个小时左右从生产数据库更新一次。我正在使用python脚本和psycopg2来实现这一点。我可以使用以下代码复制一些表:

speedy_serve_cursor = speedy_serve_con.cursor()
archives_cursor = archives_con.cursor()

speedy_serve_cursor.execute('SELECT * from "TranslatableItems"')

for row in speedy_serve_cursor.fetchall():
    archives_cursor.execute('INSERT INTO "TranslatableItems" VALUES %s',(row,))

archives_con.commit()
这适用于某些表,但有些表具有多个外键约束,需要我首先复制父表。我得到错误“插入或更新表违反外键约束”。如何查找所有父表或一次复制所有链接表