mirror of
https://github.com/python/cpython.git
synced 2025-10-28 01:00:34 +00:00
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.
This commit is contained in:
parent
5c08ce9bf7
commit
287b84de93
26 changed files with 52 additions and 19 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue