summaryrefslogtreecommitdiffstats
path: root/Doc/includes/sqlite3/ctx_manager.py
diff options
context:
space:
mode:
authorXtreak <tir.karthi@gmail.com>2019-05-19 21:52:20 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2019-05-19 21:52:20 (GMT)
commit287b84de939db47aa8c6f30734ceb8aba9d1db29 (patch)
tree0c492acbe1135b59f30a0dc8aa5bfd0705387371 /Doc/includes/sqlite3/ctx_manager.py
parent5c08ce9bf712acbb3f05a3a57baf51fcb534cdf0 (diff)
downloadcpython-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/includes/sqlite3/ctx_manager.py')
-rw-r--r--Doc/includes/sqlite3/ctx_manager.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/includes/sqlite3/ctx_manager.py b/Doc/includes/sqlite3/ctx_manager.py
index 7af4ad1..6db77d4 100644
--- a/Doc/includes/sqlite3/ctx_manager.py
+++ b/Doc/includes/sqlite3/ctx_manager.py
@@ -14,3 +14,7 @@ try:
con.execute("insert into person(firstname) values (?)", ("Joe",))
except sqlite3.IntegrityError:
print("couldn't add Joe twice")
+
+# Connection object used as context manager only commits or rollbacks transactions,
+# so the connection object should be closed manually
+con.close()