mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-45243: Add support for setting/getting sqlite3
connection limits (GH-28463)
This commit is contained in:
parent
e2063d6a1e
commit
b6b38a8226
7 changed files with 228 additions and 1 deletions
|
@ -662,6 +662,40 @@ Connection Objects
|
|||
.. versionadded:: 3.7
|
||||
|
||||
|
||||
.. method:: getlimit(category, /)
|
||||
|
||||
Get a connection run-time limit. *category* is the limit category to be
|
||||
queried.
|
||||
|
||||
Example, query the maximum length of an SQL statement::
|
||||
|
||||
import sqlite3
|
||||
con = sqlite3.connect(":memory:")
|
||||
lim = con.getlimit(sqlite3.SQLITE_LIMIT_SQL_LENGTH)
|
||||
print(f"SQLITE_LIMIT_SQL_LENGTH={lim}")
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
|
||||
.. method:: setlimit(category, limit, /)
|
||||
|
||||
Set a connection run-time limit. *category* is the limit category to be
|
||||
set. *limit* is the new limit. If the new limit is a negative number, the
|
||||
limit is unchanged.
|
||||
|
||||
Attempts to increase a limit above its hard upper bound are silently
|
||||
truncated to the hard upper bound. Regardless of whether or not the limit
|
||||
was changed, the prior value of the limit is returned.
|
||||
|
||||
Example, limit the number of attached databases to 1::
|
||||
|
||||
import sqlite3
|
||||
con = sqlite3.connect(":memory:")
|
||||
con.setlimit(sqlite3.SQLITE_LIMIT_ATTACHED, 1)
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
|
||||
.. _sqlite3-cursor-objects:
|
||||
|
||||
Cursor Objects
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue