This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cur.executemany("INSERT INTO data VALUES(?)", rows)
.. testcleanup:: sqlite3.cursor
con.close()
.. note::
Any resulting rows are discarded,
Expand Down
Expand Up
@@ -1613,6 +1628,7 @@ Cursor objects
>>> cur = con.cursor()
>>> cur.connection == con
True
>>> con.close()
.. attribute:: description
Expand Down
Expand Up
@@ -1733,6 +1749,7 @@ Blob objects
greeting = blob.read()
print(greeting) # outputs "b'Hello, world!'"
con.close()
.. testoutput::
:hide:
Expand Down
Expand Up
@@ -2045,6 +2062,7 @@ Here's an example of both styles:
params = (1972,)
cur.execute("SELECT * FROM lang WHERE first_appeared = ?", params)
print(cur.fetchall())
con.close()
.. testoutput::
:hide:
Expand Down
Expand Up
@@ -2103,6 +2121,7 @@ The object passed to *protocol* will be of type :class:`PrepareProtocol`.
cur.execute("SELECT ?", (Point(4.0, -3.2),))
print(cur.fetchone()[0])
con.close()
.. testoutput::
:hide:
Expand Down
Expand Up
@@ -2133,6 +2152,7 @@ This function can then be registered using :func:`register_adapter`.
cur.execute("SELECT ?", (Point(1.0, 2.5),))
print(cur.fetchone()[0])
con.close()
.. testoutput::
:hide:
Expand Down
Expand Up
@@ -2217,6 +2237,8 @@ The following example illustrates the implicit and explicit approaches:
cur.execute("INSERT INTO test(p) VALUES(?)", (p,))
cur.execute('SELECT p AS "p [point]" FROM test')
print("with column names:", cur.fetchone()[0])
cur.close()
con.close()
.. testoutput::
:hide:
Expand Down
Expand Up
@@ -2423,6 +2445,8 @@ Some useful URI tricks include:
res = con2.execute("SELECT data FROM shared")
assert res.fetchone() == (28,)
con1.close()
con2.close()
More information about this feature, including a list of parameters,
can be found in the `SQLite URI documentation`_.
Expand Down
Expand Up
@@ -2469,6 +2493,7 @@ Queries now return :class:`!Row` objects:
'Earth'
>>> row["RADIUS"] # Column names are case-insensitive.
6378
>>> con.close()
.. note::
Expand All
@@ -2495,6 +2520,7 @@ Using it, queries now return a :class:`!dict` instead of a :class:`!tuple`:
>>> for row in con.execute("SELECT 1 AS a, 2 AS b"):
... print(row)
{'a': 1, 'b': 2}
>>> con.close()
The following row factory returns a :term:`named tuple`:
Expand All
@@ -2521,6 +2547,7 @@ The following row factory returns a :term:`named tuple`:
1
>>> row.b # Attribute access.
2
>>> con.close()
With some adjustments, the above recipe can be adapted to use a
:class:`~dataclasses.dataclass`, or any other custom class,
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[3.12] gh-111726: Explicitly close database connections in sqlite3 doctests (GH-111730) #117630
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
[3.12] gh-111726: Explicitly close database connections in sqlite3 doctests (GH-111730) #117630
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing