diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-05-19 15:36:32 -0700 |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2019-05-20 01:36:32 +0300 |
commit | 205c1f0e36e00e6e7cb7fbabaab4f52732859f9e (patch) | |
tree | 18a634c9d26ed3182b6d377f6dbe91b978148414 /Doc/library | |
parent | f393e8eb463d60ce559982613429568c518ab8d9 (diff) | |
download | cpython-git-205c1f0e36e00e6e7cb7fbabaab4f52732859f9e.tar.gz |
bpo-34580: Update sqlite3 examples to call close() explicitly (GH-9079)
The sqlite3.Connection object doesn't call its close() method when it's used
as a context manager.
(cherry picked from commit 287b84de939db47aa8c6f30734ceb8aba9d1db29)
Co-authored-by: Xtreak <tir.karthi@gmail.com>
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/sqlite3.rst | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 569bfced38..e20b4b3db3 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -530,6 +530,7 @@ Connection Objects with open('dump.sql', 'w') as f: for line in con.iterdump(): f.write('%s\n' % line) + con.close() .. method:: backup(target, *, pages=0, progress=None, name="main", sleep=0.250) @@ -566,8 +567,11 @@ Connection Objects print(f'Copied {total-remaining} of {total} pages...') con = sqlite3.connect('existing_db.db') - with sqlite3.connect('backup.db') as bck: + bck = sqlite3.connect('backup.db') + with bck: con.backup(bck, pages=1, progress=progress) + bck.close() + con.close() Example 2, copy an existing database into a transient copy:: |