@@ -149,24 +149,25 @@ Module functions and constants
149
149
150
150
.. data :: version
151
151
152
- The version number of this module, as a string. This is not the version of
153
- the SQLite library.
152
+ Version number of this module as a :class: ` string <str> `.
153
+ This is not the version of the SQLite library.
154
154
155
155
156
156
.. data :: version_info
157
157
158
- The version number of this module, as a tuple of integers. This is not the
159
- version of the SQLite library.
158
+ Version number of this module as a :class: ` tuple ` of :class: ` integers <int> `.
159
+ This is not the version of the SQLite library.
160
160
161
161
162
162
.. data :: sqlite_version
163
163
164
- The version number of the run-time SQLite library, as a string.
164
+ Version number of the runtime SQLite library as a :class: ` string <str> ` .
165
165
166
166
167
167
.. data :: sqlite_version_info
168
168
169
- The version number of the run-time SQLite library, as a tuple of integers.
169
+ Version number of the runtime SQLite library as a :class: `tuple ` of
170
+ :class: `integers <int> `.
170
171
171
172
172
173
.. data :: threadsafety
@@ -369,6 +370,7 @@ Module functions and constants
369
370
370
371
.. function :: enable_callback_tracebacks(flag, /)
371
372
373
+ Enable or disable callback tracebacks.
372
374
By default you will not get any tracebacks in user-defined functions,
373
375
aggregates, converters, authorizer callbacks etc. If you want to debug them,
374
376
you can call this function with *flag * set to :const: `True `. Afterwards, you
@@ -428,6 +430,7 @@ Connection Objects
428
430
429
431
.. method :: cursor(factory=Cursor)
430
432
433
+ Create and return a :class: `Cursor ` object.
431
434
The cursor method accepts a single optional parameter *factory *. If
432
435
supplied, this must be a callable returning an instance of :class: `Cursor `
433
436
or its subclasses.
@@ -638,9 +641,9 @@ Connection Objects
638
641
639
642
.. method :: interrupt()
640
643
641
- You can call this method from a different thread to abort any queries that might
642
- be executing on the connection. The query will then abort and the caller will
643
- get an exception.
644
+ Call this method from a different thread to abort any queries that might
645
+ be executing on the connection.
646
+ Aborted queries will raise an exception.
644
647
645
648
646
649
.. method :: set_authorizer(authorizer_callback)
@@ -745,10 +748,9 @@ Connection Objects
745
748
746
749
.. attribute :: row_factory
747
750
748
- You can change this attribute to a callable that accepts the cursor and the
749
- original row as a tuple and will return the real result row. This way, you can
750
- implement more advanced ways of returning results, such as returning an object
751
- that can also access columns by name.
751
+ A callable that accepts two arguments,
752
+ a :class: `Cursor ` object and the raw row results as a :class: `tuple `,
753
+ and returns a custom object representing an SQLite row.
752
754
753
755
Example:
754
756
@@ -766,31 +768,28 @@ Connection Objects
766
768
767
769
.. attribute :: text_factory
768
770
769
- Using this attribute you can control what objects are returned for the ``TEXT ``
770
- data type. By default, this attribute is set to :class: `str ` and the
771
- :mod: `sqlite3 ` module will return :class: `str ` objects for ``TEXT ``.
772
- If you want to return :class: `bytes ` instead, you can set it to :class: `bytes `.
771
+ A callable that accepts a :class: `bytes ` parameter and returns a text
772
+ representation of it.
773
+ The callable is invoked for SQLite values with the ``TEXT `` data type.
774
+ By default, this attribute is set to :class: `str `.
775
+ If you want to return ``bytes `` instead, set *text_factory * to ``bytes ``.
773
776
774
- You can also set it to any other callable that accepts a single bytestring
775
- parameter and returns the resulting object.
776
-
777
- See the following example code for illustration:
777
+ Example:
778
778
779
779
.. literalinclude :: ../includes/sqlite3/text_factory.py
780
780
781
781
782
782
.. attribute :: total_changes
783
783
784
- Returns the total number of database rows that have been modified, inserted, or
784
+ Return the total number of database rows that have been modified, inserted, or
785
785
deleted since the database connection was opened.
786
786
787
787
788
788
.. method :: iterdump
789
789
790
- Returns an iterator to dump the database in an SQL text format. Useful when
791
- saving an in-memory database for later restoration. This function provides
792
- the same capabilities as the :kbd: `.dump ` command in the :program: `sqlite3 `
793
- shell.
790
+ Return an :term: `iterator ` to dump the database as SQL source code.
791
+ Useful when saving an in-memory database for later restoration.
792
+ Similar to the ``.dump `` command in the :program: `sqlite3 ` shell.
794
793
795
794
Example::
796
795
@@ -871,7 +870,7 @@ Connection Objects
871
870
872
871
.. method :: getlimit(category, /)
873
872
874
- Get a connection run-time limit. *category * is the limit category to be
873
+ Get a connection runtime limit. *category * is the limit category to be
875
874
queried.
876
875
877
876
Example, query the maximum length of an SQL statement::
@@ -886,7 +885,7 @@ Connection Objects
886
885
887
886
.. method :: setlimit(category, limit, /)
888
887
889
- Set a connection run-time limit. *category * is the limit category to be
888
+ Set a connection runtime limit. *category * is the limit category to be
890
889
set. *limit * is the new limit. If the new limit is a negative number, the
891
890
limit is unchanged.
892
891
@@ -905,7 +904,7 @@ Connection Objects
905
904
906
905
.. method :: serialize(*, name="main")
907
906
908
- This method serializes a database into a :class: `bytes ` object. For an
907
+ Serialize a database into a :class: `bytes ` object. For an
909
908
ordinary on-disk database file, the serialization is just a copy of the
910
909
disk file. For an in-memory database or a "temp" database, the
911
910
serialization is the same sequence of bytes which would be written to
@@ -924,6 +923,8 @@ Connection Objects
924
923
925
924
.. method :: deserialize(data, /, *, name="main")
926
925
926
+ Deserialize a :meth: `serialized <serialize> ` database into a
927
+ :class: `Connection `.
927
928
This method causes the database connection to disconnect from database
928
929
*name *, and reopen *name * as an in-memory database based on the
929
930
serialization contained in *data *. Deserialization will raise
@@ -1003,20 +1004,20 @@ Cursor Objects
1003
1004
1004
1005
.. method :: fetchone()
1005
1006
1006
- Fetches the next row of a query result set, returning a single sequence,
1007
- or :const: `None ` when no more data is available.
1007
+ Fetch the next row of a query result set as a :class: ` tuple `.
1008
+ Return :const: `None ` if no more data is available.
1008
1009
1009
1010
1010
1011
.. method :: fetchmany(size=cursor.arraysize)
1011
1012
1012
- Fetches the next set of rows of a query result, returning a list. An empty
1013
- list is returned when no more rows are available.
1013
+ Fetch the next set of rows of a query result as a :class: ` list `.
1014
+ Return an empty list if no more rows are available.
1014
1015
1015
1016
The number of rows to fetch per call is specified by the *size * parameter.
1016
- If it is not given, the cursor's arraysize determines the number of rows
1017
- to be fetched. The method should try to fetch as many rows as indicated by
1018
- the size parameter. If this is not possible due to the specified number of
1019
- rows not being available, fewer rows may be returned.
1017
+ If * size * is not given, :attr: ` arraysize ` determines the number of rows
1018
+ to be fetched.
1019
+ If fewer than * size * rows are available,
1020
+ as many rows as are available are returned.
1020
1021
1021
1022
Note there are performance considerations involved with the *size * parameter.
1022
1023
For optimal performance, it is usually best to use the arraysize attribute.
@@ -1025,9 +1026,10 @@ Cursor Objects
1025
1026
1026
1027
.. method :: fetchall()
1027
1028
1028
- Fetches all (remaining) rows of a query result, returning a list. Note that
1029
- the cursor's arraysize attribute can affect the performance of this operation.
1030
- An empty list is returned when no rows are available.
1029
+ Fetch all (remaining) rows of a query result as a :class: `list `.
1030
+ Return an empty list if no rows are available.
1031
+ Note that the :attr: `arraysize ` attribute can affect the performance of
1032
+ this operation.
1031
1033
1032
1034
.. method :: close()
1033
1035
@@ -1054,7 +1056,7 @@ Cursor Objects
1054
1056
1055
1057
.. attribute :: lastrowid
1056
1058
1057
- This read -only attribute provides the row id of the last inserted row. It
1059
+ Read -only attribute that provides the row id of the last inserted row. It
1058
1060
is only updated after successful ``INSERT `` or ``REPLACE `` statements
1059
1061
using the :meth: `execute ` method. For other statements, after
1060
1062
:meth: `executemany ` or :meth: `executescript `, or if the insertion failed,
@@ -1074,16 +1076,16 @@ Cursor Objects
1074
1076
1075
1077
.. attribute :: description
1076
1078
1077
- This read -only attribute provides the column names of the last query. To
1079
+ Read -only attribute that provides the column names of the last query. To
1078
1080
remain compatible with the Python DB API, it returns a 7-tuple for each
1079
1081
column where the last six items of each tuple are :const: `None `.
1080
1082
1081
1083
It is set for ``SELECT `` statements without any matching rows as well.
1082
1084
1083
1085
.. attribute :: connection
1084
1086
1085
- This read -only attribute provides the SQLite database :class: `Connection `
1086
- used by the :class: ` Cursor ` object . A :class: `Cursor ` object created by
1087
+ Read -only attribute that provides the SQLite database :class: `Connection `
1088
+ belonging to the cursor . A :class: `Cursor ` object created by
1087
1089
calling :meth: `con.cursor() <Connection.cursor> ` will have a
1088
1090
:attr: `connection ` attribute that refers to *con *::
1089
1091
@@ -1111,7 +1113,8 @@ Row Objects
1111
1113
1112
1114
.. method :: keys
1113
1115
1114
- This method returns a list of column names. Immediately after a query,
1116
+ Return a :class: `list ` of column names as :class: `strings <str> `.
1117
+ Immediately after a query,
1115
1118
it is the first member of each tuple in :attr: `Cursor.description `.
1116
1119
1117
1120
.. versionchanged :: 3.5
0 commit comments