Return an iterator to dump the database as SQL source code.
The current implementation has several drawbacks compared to the SQLite shell .dump command. We should try to align our implementation with the .dump command of the SQLite shell.
The SQLite shell always starts the dump by disabling foreign key support. It has been doing so for a long time:
$ ~/install/sqlite-3.42.0/bin/sqlite3SQLite version 3.42.0 2023-05-16 12:36:15Enter ".help" for usage hints.Connected to a transient in-memory database.Use ".open FILENAME" to reopen on a persistent database.sqlite> .dumpPRAGMA foreign_keys=OFF;BEGIN TRANSACTION;COMMIT;sqlite> ^D
$ ~/install/sqlite-3.7.15/bin/sqlite3SQLite version 3.7.15 2012-12-12 13:36:53Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite> .dumpPRAGMA foreign_keys=OFF;BEGIN TRANSACTION;COMMIT;sqlite> ^D
I suggest we align to this practise.
In SQLite foreign key support is always disabled by default; one has to explicitly enable it, if needed.
I'm closing this issue, since it has no more actionable items; instead, we can open better targeted issues for specific .dump features we would like to add to .iterdump().
Activity
erlend-aasland commented on Aug 25, 2023
The SQLite shell always starts the dump by disabling foreign key support. It has been doing so for a long time:
I suggest we align to this practise.
In SQLite foreign key support is always disabled by default; one has to explicitly enable it, if needed.
pythongh-108364: In sqlite3, disable foreign keys before dumping SQL …
erlend-aasland commented on Aug 25, 2023
I restyled this as a feature, not a bugfix.
pythongh-108364: Simplify quoting values/identifiers in sqlite3.dump.…
gh-108364: Simplify quoting values and identifiers in sqlite3's iterd…
erlend-aasland commented on Aug 29, 2023
cc. @EddInSverige
erlend-aasland commented on Aug 30, 2023
FTR, here's the SQLite shell C code:
https://sqlite.org/src/file?name=src/shell.c.in&ci=trunk
pythongh-108364: In sqlite3, disable foreign keys before dumping SQL …
pythongh-108364: In sqlite3, disable foreign keys before dumping SQL …
gh-108364: In sqlite3, disable foreign keys before dumping SQL schema (…
erlend-aasland commented on Jan 12, 2024
I'm closing this issue, since it has no more actionable items; instead, we can open better targeted issues for specific .dump features we would like to add to .iterdump().
pythongh-108364: In sqlite3, disable foreign keys before dumping SQL …
pythongh-108364: In sqlite3, disable foreign keys before dumping SQL …
pythongh-108364: In sqlite3, disable foreign keys before dumping SQL …