summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/dump.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/sqlite3/dump.py')
-rw-r--r--Lib/sqlite3/dump.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py
index ead3360..719dfc8 100644
--- a/Lib/sqlite3/dump.py
+++ b/Lib/sqlite3/dump.py
@@ -26,6 +26,10 @@ def _iterdump(connection):
writeable_schema = False
cu = connection.cursor()
+ # Disable foreign key constraints, if there is any foreign key violation.
+ violations = cu.execute("PRAGMA foreign_key_check").fetchall()
+ if violations:
+ yield('PRAGMA foreign_keys=OFF;')
yield('BEGIN TRANSACTION;')
# sqlite_master table contains the SQL CREATE statements for the database.