@@ -295,15 +295,14 @@ Module functions and constants
295
295
in RAM instead of on disk.
296
296
:type database: :term: `path-like object `
297
297
298
- :param timeout:
298
+ :param float timeout:
299
299
How many seconds the connection should wait before raising
300
300
an exception, if the database is locked by another connection.
301
301
If another connection opens a transaction to modify the database,
302
302
it will be locked until that transaction is committed.
303
303
Default five seconds.
304
- :type timeout: float
305
304
306
- :param detect_types:
305
+ :param int detect_types:
307
306
Control whether and how data types not
308
307
:ref: `natively supported by SQLite <sqlite3-types >`
309
308
are looked up to be converted to Python types,
@@ -316,7 +315,6 @@ Module functions and constants
316
315
even when the *detect_types * parameter is set; :class: `str ` will be
317
316
returned instead.
318
317
By default (``0 ``), type detection is disabled.
319
- :type detect_types: int
320
318
321
319
:param isolation_level:
322
320
The :attr: `~Connection.isolation_level ` of the connection,
@@ -326,33 +324,29 @@ Module functions and constants
326
324
See :ref: `sqlite3-controlling-transactions ` for more.
327
325
:type isolation_level: str | None
328
326
329
- :param check_same_thread:
327
+ :param bool check_same_thread:
330
328
If ``True `` (default), only the creating thread may use the connection.
331
329
If ``False ``, the connection may be shared across multiple threads;
332
330
if so, write operations should be serialized by the user to avoid data
333
331
corruption.
334
- :type check_same_thread: bool
335
332
336
- :param factory:
333
+ :param Connection factory:
337
334
A custom subclass of :class: `Connection ` to create the connection with,
338
335
if not the default :class: `Connection ` class.
339
- :type factory: :class: `Connection `
340
336
341
- :param cached_statements:
337
+ :param int cached_statements:
342
338
The number of statements that ``sqlite3 ``
343
339
should internally cache for this connection, to avoid parsing overhead.
344
340
By default, 128 statements.
345
- :type cached_statements: int
346
341
347
- :param uri:
342
+ :param bool uri:
348
343
If set to ``True ``, *database * is interpreted as a
349
344
:abbr: `URI ( Uniform Resource Identifier ) ` with a file path
350
345
and an optional query string.
351
346
The scheme part *must * be ``"file:" ``,
352
347
and the path can be relative or absolute.
353
348
The query string allows passing parameters to SQLite,
354
349
enabling various :ref: `sqlite3-uri-tricks `.
355
- :type uri: bool
356
350
357
351
:rtype: Connection
358
352
@@ -487,28 +481,23 @@ Connection objects
487
481
Open a :class: `Blob ` handle to an existing
488
482
:abbr: `BLOB ( Binary Large OBject ) `.
489
483
490
- :param table:
484
+ :param str table:
491
485
The name of the table where the blob is located.
492
- :type table: str
493
486
494
- :param column:
487
+ :param str column:
495
488
The name of the column where the blob is located.
496
- :type column: str
497
489
498
- :param row:
490
+ :param str row:
499
491
The name of the row where the blob is located.
500
- :type row: str
501
492
502
- :param readonly:
493
+ :param bool readonly:
503
494
Set to ``True `` if the blob should be opened without write
504
495
permissions.
505
496
Defaults to ``False ``.
506
- :type readonly: bool
507
497
508
- :param name:
498
+ :param str name:
509
499
The name of the database where the blob is located.
510
500
Defaults to ``"main" ``.
511
- :type name: str
512
501
513
502
:raises OperationalError:
514
503
When trying to open a blob in a ``WITHOUT ROWID `` table.
@@ -561,14 +550,12 @@ Connection objects
561
550
562
551
Create or remove a user-defined SQL function.
563
552
564
- :param name:
553
+ :param str name:
565
554
The name of the SQL function.
566
- :type name: str
567
555
568
- :param narg:
556
+ :param int narg:
569
557
The number of arguments the SQL function can accept.
570
558
If ``-1 ``, it may take any number of arguments.
571
- :type narg: int
572
559
573
560
:param func:
574
561
A callable that is called when the SQL function is invoked.
@@ -577,11 +564,10 @@ Connection objects
577
564
Set to ``None `` to remove an existing SQL function.
578
565
:type func: :term: `callback ` | None
579
566
580
- :param deterministic:
567
+ :param bool deterministic:
581
568
If ``True ``, the created SQL function is marked as
582
569
`deterministic <https://sqlite.org/deterministic.html >`_,
583
570
which allows SQLite to perform additional optimizations.
584
- :type deterministic: bool
585
571
586
572
:raises NotSupportedError:
587
573
If *deterministic * is used with SQLite versions older than 3.8.3.
@@ -598,14 +584,12 @@ Connection objects
598
584
599
585
Create or remove a user-defined SQL aggregate function.
600
586
601
- :param name:
587
+ :param str name:
602
588
The name of the SQL aggregate function.
603
- :type name: str
604
589
605
- :param n_arg:
590
+ :param int n_arg:
606
591
The number of arguments the SQL aggregate function can accept.
607
592
If ``-1 ``, it may take any number of arguments.
608
- :type n_arg: int
609
593
610
594
:param aggregate_class:
611
595
A class must implement the following methods:
@@ -629,14 +613,12 @@ Connection objects
629
613
630
614
Create or remove a user-defined aggregate window function.
631
615
632
- :param name:
616
+ :param str name:
633
617
The name of the SQL aggregate window function to create or remove.
634
- :type name: str
635
618
636
- :param num_params:
619
+ :param int num_params:
637
620
The number of arguments the SQL aggregate window function can accept.
638
621
If ``-1 ``, it may take any number of arguments.
639
- :type num_params: int
640
622
641
623
:param aggregate_class:
642
624
A class that must implement the following methods:
@@ -862,16 +844,14 @@ Connection objects
862
844
Works even if the database is being accessed by other clients
863
845
or concurrently by the same connection.
864
846
865
- :param target:
847
+ :param Connection target:
866
848
The database connection to save the backup to.
867
- :type target: Connection
868
849
869
- :param pages:
850
+ :param int pages:
870
851
The number of pages to copy at a time.
871
852
If equal to or less than ``0 ``,
872
853
the entire database is copied in a single step.
873
854
Defaults to ``-1 ``.
874
- :type pages: int
875
855
876
856
:param progress:
877
857
If set to a callable, it is invoked with three integer arguments for
@@ -882,18 +862,16 @@ Connection objects
882
862
Defaults to ``None ``.
883
863
:type progress: :term: `callback ` | None
884
864
885
- :param name:
865
+ :param str name:
886
866
The name of the database to back up.
887
867
Either ``"main" `` (the default) for the main database,
888
868
``"temp" `` for the temporary database,
889
869
or the name of a custom database as attached using the
890
870
``ATTACH DATABASE `` SQL statement.
891
- :type name: str
892
871
893
- :param sleep:
872
+ :param float sleep:
894
873
The number of seconds to sleep between successive attempts
895
874
to back up remaining pages.
896
- :type sleep: float
897
875
898
876
Example 1, copy an existing database into another::
899
877
@@ -919,11 +897,17 @@ Connection objects
919
897
920
898
.. versionadded :: 3.7
921
899
922
-
923
900
.. method :: getlimit(category, /)
924
901
925
- Get a connection runtime limit. *category * is the limit category to be
926
- queried.
902
+ Get a connection runtime limit.
903
+
904
+ :param int category:
905
+ The `SQLite limit category `_ to be queried.
906
+
907
+ :rtype: int
908
+
909
+ :raises ProgrammingError:
910
+ If *category * is not recognised by the underlying SQLite library.
927
911
928
912
Example, query the maximum length of an SQL statement::
929
913
@@ -937,14 +921,23 @@ Connection objects
937
921
938
922
.. method :: setlimit(category, limit, /)
939
923
940
- Set a connection runtime limit. *category * is the limit category to be
941
- set. *limit * is the new limit. If the new limit is a negative number, the
942
- limit is unchanged.
943
-
924
+ Set a connection runtime limit.
944
925
Attempts to increase a limit above its hard upper bound are silently
945
926
truncated to the hard upper bound. Regardless of whether or not the limit
946
927
was changed, the prior value of the limit is returned.
947
928
929
+ :param int category:
930
+ The `SQLite limit category `_ to be set.
931
+
932
+ :param int limit:
933
+ The value of the new limit.
934
+ If negative, the current limit is unchanged.
935
+
936
+ :rtype: int
937
+
938
+ :raises ProgrammingError:
939
+ If *category * is not recognised by the underlying SQLite library.
940
+
948
941
Example, limit the number of attached databases to 1::
949
942
950
943
import sqlite3
@@ -953,6 +946,8 @@ Connection objects
953
946
954
947
.. versionadded :: 3.11
955
948
949
+ .. _SQLite limit category : https://www.sqlite.org/c3ref/c_limit_attached.html
950
+
956
951
957
952
.. method :: serialize(*, name="main")
958
953
@@ -962,8 +957,11 @@ Connection objects
962
957
serialization is the same sequence of bytes which would be written to
963
958
disk if that database were backed up to disk.
964
959
965
- *name * is the database to be serialized, and defaults to the main
966
- database.
960
+ :param str name:
961
+ The database name to be serialized.
962
+ Defaults to ``"main" ``.
963
+
964
+ :rtype: bytes
967
965
968
966
.. note ::
969
967
@@ -979,12 +977,24 @@ Connection objects
979
977
:class: `Connection `.
980
978
This method causes the database connection to disconnect from database
981
979
*name *, and reopen *name * as an in-memory database based on the
982
- serialization contained in *data *. Deserialization will raise
983
- :exc: `OperationalError ` if the database connection is currently involved
984
- in a read transaction or a backup operation. :exc: `OverflowError ` will be
985
- raised if ``len(data) `` is larger than ``2**63 - 1 ``, and
986
- :exc: `DatabaseError ` will be raised if *data * does not contain a valid
987
- SQLite database.
980
+ serialization contained in *data *.
981
+
982
+ :param bytes data:
983
+ A serialized database.
984
+
985
+ :param str name:
986
+ The database name to deserialize into.
987
+ Defaults to ``"main" ``.
988
+
989
+ :raises OperationalError:
990
+ If the database connection is currently involved in a read
991
+ transaction or a backup operation.
992
+
993
+ :raises DatabaseError:
994
+ If *data * does not contain a valid SQLite database.
995
+
996
+ :raises OverflowError:
997
+ If :func: `len(data) <len> ` is larger than ``2**63 - 1 ``.
988
998
989
999
.. note ::
990
1000
@@ -1081,13 +1091,13 @@ Cursor objects
1081
1091
1082
1092
.. method :: fetchone()
1083
1093
1084
- Fetch the next row of a query result set as a :class: `tuple `.
1094
+ Return the next row of a query result set as a :class: `tuple `.
1085
1095
Return ``None `` if no more data is available.
1086
1096
1087
1097
1088
1098
.. method :: fetchmany(size=cursor.arraysize)
1089
1099
1090
- Fetch the next set of rows of a query result as a :class: `list `.
1100
+ Return the next set of rows of a query result as a :class: `list `.
1091
1101
Return an empty list if no more rows are available.
1092
1102
1093
1103
The number of rows to fetch per call is specified by the *size * parameter.
@@ -1103,7 +1113,7 @@ Cursor objects
1103
1113
1104
1114
.. method :: fetchall()
1105
1115
1106
- Fetch all (remaining) rows of a query result as a :class: `list `.
1116
+ Return all (remaining) rows of a query result as a :class: `list `.
1107
1117
Return an empty list if no rows are available.
1108
1118
Note that the :attr: `arraysize ` attribute can affect the performance of
1109
1119
this operation.
0 commit comments