diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-05-19 21:52:20 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2019-05-19 21:52:20 (GMT) |
commit | 287b84de939db47aa8c6f30734ceb8aba9d1db29 (patch) | |
tree | 0c492acbe1135b59f30a0dc8aa5bfd0705387371 /Doc/library/sqlite3.rst | |
parent | 5c08ce9bf712acbb3f05a3a57baf51fcb534cdf0 (diff) | |
download | cpython-287b84de939db47aa8c6f30734ceb8aba9d1db29.zip cpython-287b84de939db47aa8c6f30734ceb8aba9d1db29.tar.gz cpython-287b84de939db47aa8c6f30734ceb8aba9d1db29.tar.bz2 |
bpo-34580: Update sqlite3 examples to call close() explicitly (GH-9079)
The sqlit3.Connection object doesn't call its close() method when it's used
as a context manager.
Diffstat (limited to 'Doc/library/sqlite3.rst')
-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 37087ac..20fca54 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -537,6 +537,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) @@ -573,8 +574,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:: |