summaryrefslogtreecommitdiff
path: root/Doc/library/sqlite3.rst
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-03-28 08:32:09 +0000
committerGregory P. Smith <greg@mad-scientist.com>2008-03-28 08:32:09 +0000
commitb9803421d231fc66489eafb45f6ae440010cacfc (patch)
treec934cab8654aef8bc092f4a70d3fddfc9e34fa51 /Doc/library/sqlite3.rst
parent621cd262539cd6bea59bb1c3cfc35b9d37a26d98 (diff)
downloadcpython-git-b9803421d231fc66489eafb45f6ae440010cacfc.tar.gz
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.rst21
1 files changed, 21 insertions, 0 deletions
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 6c6cf0349a..da313fd597 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