@@ -222,10 +222,7 @@ creating a new cursor, then querying the database:
222222 >>> title, year = res.fetchone()
223223 >>> print (f ' The highest scoring Monty Python movie is { title!r } , released in { year} ' )
224224 The highest scoring Monty Python movie is 'Monty Python and the Holy Grail', released in 1975
225-
226- .. testcleanup ::
227-
228- new_con.close()
225+ >>> new_con.close()
229226
230227You've now created an SQLite database using the :mod: `!sqlite3 ` module,
231228inserted data and retrieved values from it in multiple ways.
@@ -750,10 +747,7 @@ Connection objects
750747 >>> for row in con.execute(" SELECT md5(?)" , (b " foo" ,)):
751748 ... print (row)
752749 ('acbd18db4cc2f85cedef654fccc4a4d8',)
753-
754- .. testcleanup ::
755-
756- con.close()
750+ >>> con.close()
757751
758752 .. versionchanged :: 3.13
759753
@@ -1248,10 +1242,6 @@ Connection objects
12481242 >>> con.getlimit(sqlite3.SQLITE_LIMIT_SQL_LENGTH )
12491243 1000000000
12501244
1251- .. testcleanup :: sqlite3.limits
1252-
1253- con.close()
1254-
12551245 .. versionadded :: 3.11
12561246
12571247
@@ -1284,6 +1274,10 @@ Connection objects
12841274 >>> con.getlimit(sqlite3.SQLITE_LIMIT_ATTACHED )
12851275 1
12861276
1277+ .. testcleanup :: sqlite3.limits
1278+
1279+ con.close()
1280+
12871281 .. versionadded :: 3.11
12881282
12891283 .. _SQLite limit category : https://www.sqlite.org/c3ref/c_limit_attached.html
@@ -1674,10 +1668,7 @@ Cursor objects
16741668 >>> cur = con.cursor()
16751669 >>> cur.connection == con
16761670 True
1677-
1678- .. testcleanup ::
1679-
1680- con.close()
1671+ >>> con.close()
16811672
16821673 .. attribute :: description
16831674
@@ -2528,10 +2519,6 @@ assign it to the :attr:`!row_factory` attribute:
25282519 >>> con = sqlite3.connect(" :memory:" )
25292520 >>> con.row_factory = sqlite3.Row
25302521
2531- .. testcleanup ::
2532-
2533- con.close()
2534-
25352522Queries now return :class: `!Row ` objects:
25362523
25372524.. doctest ::
@@ -2546,10 +2533,7 @@ Queries now return :class:`!Row` objects:
25462533 'Earth'
25472534 >>> row[" RADIUS" ] # Column names are case-insensitive.
25482535 6378
2549-
2550- .. testcleanup ::
2551-
2552- con.close()
2536+ >>> con.close()
25532537
25542538.. note ::
25552539
@@ -2576,10 +2560,7 @@ Using it, queries now return a :class:`!dict` instead of a :class:`!tuple`:
25762560 >>> for row in con.execute(" SELECT 1 AS a, 2 AS b" ):
25772561 ... print (row)
25782562 {'a': 1, 'b': 2}
2579-
2580- .. testcleanup ::
2581-
2582- con.close()
2563+ >>> con.close()
25832564
25842565The following row factory returns a :term: `named tuple `:
25852566
@@ -2606,10 +2587,7 @@ The following row factory returns a :term:`named tuple`:
26062587 1
26072588 >>> row.b # Attribute access.
26082589 2
2609-
2610- .. testcleanup ::
2611-
2612- con.close()
2590+ >>> con.close()
26132591
26142592With some adjustments, the above recipe can be adapted to use a
26152593:class: `~dataclasses.dataclass `, or any other custom class,
0 commit comments