@@ -285,15 +285,14 @@ Module functions and constants
285
285
in RAM instead of on disk.
286
286
:type database: :term: `path-like object `
287
287
288
- :param timeout:
288
+ :param float timeout:
289
289
How many seconds the connection should wait before raising
290
290
an exception, if the database is locked by another connection.
291
291
If another connection opens a transaction to modify the database,
292
292
it will be locked until that transaction is committed.
293
293
Default five seconds.
294
- :type timeout: float
295
294
296
- :param detect_types:
295
+ :param int detect_types:
297
296
Control whether and how data types not
298
297
:ref: `natively supported by SQLite <sqlite3-types >`
299
298
are looked up to be converted to Python types,
@@ -306,7 +305,6 @@ Module functions and constants
306
305
even when the *detect_types * parameter is set; :class: `str ` will be
307
306
returned instead.
308
307
By default (``0 ``), type detection is disabled.
309
- :type detect_types: int
310
308
311
309
:param isolation_level:
312
310
The :attr: `~Connection.isolation_level ` of the connection,
@@ -316,33 +314,29 @@ Module functions and constants
316
314
See :ref: `sqlite3-controlling-transactions ` for more.
317
315
:type isolation_level: str | None
318
316
319
- :param check_same_thread:
317
+ :param bool check_same_thread:
320
318
If ``True `` (default), only the creating thread may use the connection.
321
319
If ``False ``, the connection may be shared across multiple threads;
322
320
if so, write operations should be serialized by the user to avoid data
323
321
corruption.
324
- :type check_same_thread: bool
325
322
326
- :param factory:
323
+ :param Connection factory:
327
324
A custom subclass of :class: `Connection ` to create the connection with,
328
325
if not the default :class: `Connection ` class.
329
- :type factory: :class: `Connection `
330
326
331
- :param cached_statements:
327
+ :param int cached_statements:
332
328
The number of statements that ``sqlite3 ``
333
329
should internally cache for this connection, to avoid parsing overhead.
334
330
By default, 128 statements.
335
- :type cached_statements: int
336
331
337
- :param uri:
332
+ :param bool uri:
338
333
If set to ``True ``, *database * is interpreted as a
339
334
:abbr: `URI ( Uniform Resource Identifier ) ` with a file path
340
335
and an optional query string.
341
336
The scheme part *must * be ``"file:" ``,
342
337
and the path can be relative or absolute.
343
338
The query string allows passing parameters to SQLite,
344
339
enabling various :ref: `sqlite3-uri-tricks `.
345
- :type uri: bool
346
340
347
341
:rtype: Connection
348
342
@@ -477,28 +471,23 @@ Connection objects
477
471
Open a :class: `Blob ` handle to an existing
478
472
:abbr: `BLOB ( Binary Large OBject ) `.
479
473
480
- :param table:
474
+ :param str table:
481
475
The name of the table where the blob is located.
482
- :type table: str
483
476
484
- :param column:
477
+ :param str column:
485
478
The name of the column where the blob is located.
486
- :type column: str
487
479
488
- :param row:
480
+ :param str row:
489
481
The name of the row where the blob is located.
490
- :type row: str
491
482
492
- :param readonly:
483
+ :param bool readonly:
493
484
Set to ``True `` if the blob should be opened without write
494
485
permissions.
495
486
Defaults to ``False ``.
496
- :type readonly: bool
497
487
498
- :param name:
488
+ :param str name:
499
489
The name of the database where the blob is located.
500
490
Defaults to ``"main" ``.
501
- :type name: str
502
491
503
492
:raises OperationalError:
504
493
When trying to open a blob in a ``WITHOUT ROWID `` table.
@@ -551,14 +540,12 @@ Connection objects
551
540
552
541
Create or remove a user-defined SQL function.
553
542
554
- :param name:
543
+ :param str name:
555
544
The name of the SQL function.
556
- :type name: str
557
545
558
- :param narg:
546
+ :param int narg:
559
547
The number of arguments the SQL function can accept.
560
548
If ``-1 ``, it may take any number of arguments.
561
- :type narg: int
562
549
563
550
:param func:
564
551
A callable that is called when the SQL function is invoked.
@@ -567,11 +554,10 @@ Connection objects
567
554
Set to ``None `` to remove an existing SQL function.
568
555
:type func: :term: `callback ` | None
569
556
570
- :param deterministic:
557
+ :param bool deterministic:
571
558
If ``True ``, the created SQL function is marked as
572
559
`deterministic <https://sqlite.org/deterministic.html >`_,
573
560
which allows SQLite to perform additional optimizations.
574
- :type deterministic: bool
575
561
576
562
:raises NotSupportedError:
577
563
If *deterministic * is used with SQLite versions older than 3.8.3.
@@ -588,14 +574,12 @@ Connection objects
588
574
589
575
Create or remove a user-defined SQL aggregate function.
590
576
591
- :param name:
577
+ :param str name:
592
578
The name of the SQL aggregate function.
593
- :type name: str
594
579
595
- :param n_arg:
580
+ :param int n_arg:
596
581
The number of arguments the SQL aggregate function can accept.
597
582
If ``-1 ``, it may take any number of arguments.
598
- :type n_arg: int
599
583
600
584
:param aggregate_class:
601
585
A class must implement the following methods:
@@ -619,14 +603,12 @@ Connection objects
619
603
620
604
Create or remove a user-defined aggregate window function.
621
605
622
- :param name:
606
+ :param str name:
623
607
The name of the SQL aggregate window function to create or remove.
624
- :type name: str
625
608
626
- :param num_params:
609
+ :param int num_params:
627
610
The number of arguments the SQL aggregate window function can accept.
628
611
If ``-1 ``, it may take any number of arguments.
629
- :type num_params: int
630
612
631
613
:param aggregate_class:
632
614
A class that must implement the following methods:
@@ -852,16 +834,14 @@ Connection objects
852
834
Works even if the database is being accessed by other clients
853
835
or concurrently by the same connection.
854
836
855
- :param target:
837
+ :param Connection target:
856
838
The database connection to save the backup to.
857
- :type target: Connection
858
839
859
- :param pages:
840
+ :param int pages:
860
841
The number of pages to copy at a time.
861
842
If equal to or less than ``0 ``,
862
843
the entire database is copied in a single step.
863
844
Defaults to ``-1 ``.
864
- :type pages: int
865
845
866
846
:param progress:
867
847
If set to a callable, it is invoked with three integer arguments for
@@ -872,18 +852,16 @@ Connection objects
872
852
Defaults to ``None ``.
873
853
:type progress: :term: `callback ` | None
874
854
875
- :param name:
855
+ :param str name:
876
856
The name of the database to back up.
877
857
Either ``"main" `` (the default) for the main database,
878
858
``"temp" `` for the temporary database,
879
859
or the name of a custom database as attached using the
880
860
``ATTACH DATABASE `` SQL statement.
881
- :type name: str
882
861
883
- :param sleep:
862
+ :param float sleep:
884
863
The number of seconds to sleep between successive attempts
885
864
to back up remaining pages.
886
- :type sleep: float
887
865
888
866
Example 1, copy an existing database into another::
889
867
@@ -909,11 +887,17 @@ Connection objects
909
887
910
888
.. versionadded :: 3.7
911
889
912
-
913
890
.. method :: getlimit(category, /)
914
891
915
- Get a connection runtime limit. *category * is the limit category to be
916
- queried.
892
+ Get a connection runtime limit.
893
+
894
+ :param int category:
895
+ The `SQLite limit category `_ to be queried.
896
+
897
+ :rtype: int
898
+
899
+ :raises ProgrammingError:
900
+ If *category * is not recognised by the underlying SQLite library.
917
901
918
902
Example, query the maximum length of an SQL statement::
919
903
@@ -927,14 +911,23 @@ Connection objects
927
911
928
912
.. method :: setlimit(category, limit, /)
929
913
930
- Set a connection runtime limit. *category * is the limit category to be
931
- set. *limit * is the new limit. If the new limit is a negative number, the
932
- limit is unchanged.
933
-
914
+ Set a connection runtime limit.
934
915
Attempts to increase a limit above its hard upper bound are silently
935
916
truncated to the hard upper bound. Regardless of whether or not the limit
936
917
was changed, the prior value of the limit is returned.
937
918
919
+ :param int category:
920
+ The `SQLite limit category `_ to be set.
921
+
922
+ :param int limit:
923
+ The value of the new limit.
924
+ If negative, the current limit is unchanged.
925
+
926
+ :rtype: int
927
+
928
+ :raises ProgrammingError:
929
+ If *category * is not recognised by the underlying SQLite library.
930
+
938
931
Example, limit the number of attached databases to 1::
939
932
940
933
import sqlite3
@@ -943,6 +936,8 @@ Connection objects
943
936
944
937
.. versionadded :: 3.11
945
938
939
+ .. _SQLite limit category : https://www.sqlite.org/c3ref/c_limit_attached.html
940
+
946
941
947
942
.. method :: serialize(*, name="main")
948
943
@@ -952,8 +947,11 @@ Connection objects
952
947
serialization is the same sequence of bytes which would be written to
953
948
disk if that database were backed up to disk.
954
949
955
- *name * is the database to be serialized, and defaults to the main
956
- database.
950
+ :param str name:
951
+ The database name to be serialized.
952
+ Defaults to ``"main" ``.
953
+
954
+ :rtype: bytes
957
955
958
956
.. note ::
959
957
@@ -969,12 +967,24 @@ Connection objects
969
967
:class: `Connection `.
970
968
This method causes the database connection to disconnect from database
971
969
*name *, and reopen *name * as an in-memory database based on the
972
- serialization contained in *data *. Deserialization will raise
973
- :exc: `OperationalError ` if the database connection is currently involved
974
- in a read transaction or a backup operation. :exc: `OverflowError ` will be
975
- raised if ``len(data) `` is larger than ``2**63 - 1 ``, and
976
- :exc: `DatabaseError ` will be raised if *data * does not contain a valid
977
- SQLite database.
970
+ serialization contained in *data *.
971
+
972
+ :param bytes data:
973
+ A serialized database.
974
+
975
+ :param str name:
976
+ The database name to deserialize into.
977
+ Defaults to ``"main" ``.
978
+
979
+ :raises OperationalError:
980
+ If the database connection is currently involved in a read
981
+ transaction or a backup operation.
982
+
983
+ :raises DatabaseError:
984
+ If *data * does not contain a valid SQLite database.
985
+
986
+ :raises OverflowError:
987
+ If :func: `len(data) <len> ` is larger than ``2**63 - 1 ``.
978
988
979
989
.. note ::
980
990
@@ -1071,13 +1081,13 @@ Cursor objects
1071
1081
1072
1082
.. method :: fetchone()
1073
1083
1074
- Fetch the next row of a query result set as a :class: `tuple `.
1084
+ Return the next row of a query result set as a :class: `tuple `.
1075
1085
Return ``None `` if no more data is available.
1076
1086
1077
1087
1078
1088
.. method :: fetchmany(size=cursor.arraysize)
1079
1089
1080
- Fetch the next set of rows of a query result as a :class: `list `.
1090
+ Return the next set of rows of a query result as a :class: `list `.
1081
1091
Return an empty list if no more rows are available.
1082
1092
1083
1093
The number of rows to fetch per call is specified by the *size * parameter.
@@ -1093,7 +1103,7 @@ Cursor objects
1093
1103
1094
1104
.. method :: fetchall()
1095
1105
1096
- Fetch all (remaining) rows of a query result as a :class: `list `.
1106
+ Return all (remaining) rows of a query result as a :class: `list `.
1097
1107
Return an empty list if no rows are available.
1098
1108
Note that the :attr: `arraysize ` attribute can affect the performance of
1099
1109
this operation.
0 commit comments