diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-03-28 08:32:09 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-03-28 08:32:09 (GMT) |
commit | b9803421d231fc66489eafb45f6ae440010cacfc (patch) | |
tree | c934cab8654aef8bc092f4a70d3fddfc9e34fa51 /Doc/library/sqlite3.rst | |
parent | 621cd262539cd6bea59bb1c3cfc35b9d37a26d98 (diff) | |
download | cpython-b9803421d231fc66489eafb45f6ae440010cacfc.zip cpython-b9803421d231fc66489eafb45f6ae440010cacfc.tar.gz cpython-b9803421d231fc66489eafb45f6ae440010cacfc.tar.bz2 |
Accept patch issue2426 by Paul Kippes (kippesp).
Adds sqlite3.Connection.iterdump to allow dumping of databases.
Diffstat (limited to 'Doc/library/sqlite3.rst')
-rw-r--r-- | Doc/library/sqlite3.rst | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 6c6cf03..da313fd 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -378,6 +378,27 @@ A :class:`Connection` instance has the following attributes and methods: deleted since the database connection was opened. +.. attribute:: Connection.iterdump + + Returns an iterator to dump the database in an SQL text format. Useful when + saving an in-memory database for later restoration. This function provides + the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3` + shell. + + .. versionadded:: 2.6 + + Example:: + + # Convert file existing_db.db to SQL dump file dump.sql + import sqlite3, os + + con = sqlite3.connect('existing_db.db') + full_dump = os.linesep.join([line for line in con.iterdump()]) + f = open('dump.sql', 'w') + f.writelines(full_dump) + f.close() + + .. _sqlite3-cursor-objects: Cursor Objects |