@@ -149,8 +149,8 @@ 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
.. deprecated-removed :: 3.12 3.14
156
156
This constant used to reflect the version number of the ``pysqlite ``
@@ -160,8 +160,8 @@ Module functions and constants
160
160
161
161
.. data :: version_info
162
162
163
- The version number of this module, as a tuple of integers. This is not the
164
- version of the SQLite library.
163
+ Version number of this module as a :class: ` tuple ` of :class: ` integers <int> `.
164
+ This is not the version of the SQLite library.
165
165
166
166
.. deprecated-removed :: 3.12 3.14
167
167
This constant used to reflect the version number of the ``pysqlite ``
@@ -171,12 +171,13 @@ Module functions and constants
171
171
172
172
.. data :: sqlite_version
173
173
174
- The version number of the run-time SQLite library, as a string.
174
+ Version number of the runtime SQLite library as a :class: ` string <str> ` .
175
175
176
176
177
177
.. data :: sqlite_version_info
178
178
179
- The version number of the run-time SQLite library, as a tuple of integers.
179
+ Version number of the runtime SQLite library as a :class: `tuple ` of
180
+ :class: `integers <int> `.
180
181
181
182
182
183
.. data :: threadsafety
@@ -379,6 +380,7 @@ Module functions and constants
379
380
380
381
.. function :: enable_callback_tracebacks(flag, /)
381
382
383
+ Enable or disable callback tracebacks.
382
384
By default you will not get any tracebacks in user-defined functions,
383
385
aggregates, converters, authorizer callbacks etc. If you want to debug them,
384
386
you can call this function with *flag * set to :const: `True `. Afterwards, you
@@ -438,6 +440,7 @@ Connection Objects
438
440
439
441
.. method :: cursor(factory=Cursor)
440
442
443
+ Create and return a :class: `Cursor ` object.
441
444
The cursor method accepts a single optional parameter *factory *. If
442
445
supplied, this must be a callable returning an instance of :class: `Cursor `
443
446
or its subclasses.
@@ -648,9 +651,9 @@ Connection Objects
648
651
649
652
.. method :: interrupt()
650
653
651
- You can call this method from a different thread to abort any queries that might
652
- be executing on the connection. The query will then abort and the caller will
653
- get an exception.
654
+ Call this method from a different thread to abort any queries that might
655
+ be executing on the connection.
656
+ Aborted queries will raise an exception.
654
657
655
658
656
659
.. method :: set_authorizer(authorizer_callback)
@@ -755,10 +758,9 @@ Connection Objects
755
758
756
759
.. attribute :: row_factory
757
760
758
- You can change this attribute to a callable that accepts the cursor and the
759
- original row as a tuple and will return the real result row. This way, you can
760
- implement more advanced ways of returning results, such as returning an object
761
- that can also access columns by name.
761
+ A callable that accepts two arguments,
762
+ a :class: `Cursor ` object and the raw row results as a :class: `tuple `,
763
+ and returns a custom object representing an SQLite row.
762
764
763
765
Example:
764
766
@@ -776,31 +778,28 @@ Connection Objects
776
778
777
779
.. attribute :: text_factory
778
780
779
- Using this attribute you can control what objects are returned for the ``TEXT ``
780
- data type. By default, this attribute is set to :class: `str ` and the
781
- :mod: `sqlite3 ` module will return :class: `str ` objects for ``TEXT ``.
782
- If you want to return :class: `bytes ` instead, you can set it to :class: `bytes `.
781
+ A callable that accepts a :class: `bytes ` parameter and returns a text
782
+ representation of it.
783
+ The callable is invoked for SQLite values with the ``TEXT `` data type.
784
+ By default, this attribute is set to :class: `str `.
785
+ If you want to return ``bytes `` instead, set *text_factory * to ``bytes ``.
783
786
784
- You can also set it to any other callable that accepts a single bytestring
785
- parameter and returns the resulting object.
786
-
787
- See the following example code for illustration:
787
+ Example:
788
788
789
789
.. literalinclude :: ../includes/sqlite3/text_factory.py
790
790
791
791
792
792
.. attribute :: total_changes
793
793
794
- Returns the total number of database rows that have been modified, inserted, or
794
+ Return the total number of database rows that have been modified, inserted, or
795
795
deleted since the database connection was opened.
796
796
797
797
798
798
.. method :: iterdump
799
799
800
- Returns an iterator to dump the database in an SQL text format. Useful when
801
- saving an in-memory database for later restoration. This function provides
802
- the same capabilities as the :kbd: `.dump ` command in the :program: `sqlite3 `
803
- shell.
800
+ Return an :term: `iterator ` to dump the database as SQL source code.
801
+ Useful when saving an in-memory database for later restoration.
802
+ Similar to the ``.dump `` command in the :program: `sqlite3 ` shell.
804
803
805
804
Example::
806
805
@@ -881,7 +880,7 @@ Connection Objects
881
880
882
881
.. method :: getlimit(category, /)
883
882
884
- Get a connection run-time limit. *category * is the limit category to be
883
+ Get a connection runtime limit. *category * is the limit category to be
885
884
queried.
886
885
887
886
Example, query the maximum length of an SQL statement::
@@ -896,7 +895,7 @@ Connection Objects
896
895
897
896
.. method :: setlimit(category, limit, /)
898
897
899
- Set a connection run-time limit. *category * is the limit category to be
898
+ Set a connection runtime limit. *category * is the limit category to be
900
899
set. *limit * is the new limit. If the new limit is a negative number, the
901
900
limit is unchanged.
902
901
@@ -915,7 +914,7 @@ Connection Objects
915
914
916
915
.. method :: serialize(*, name="main")
917
916
918
- This method serializes a database into a :class: `bytes ` object. For an
917
+ Serialize a database into a :class: `bytes ` object. For an
919
918
ordinary on-disk database file, the serialization is just a copy of the
920
919
disk file. For an in-memory database or a "temp" database, the
921
920
serialization is the same sequence of bytes which would be written to
@@ -934,6 +933,8 @@ Connection Objects
934
933
935
934
.. method :: deserialize(data, /, *, name="main")
936
935
936
+ Deserialize a :meth: `serialized <serialize> ` database into a
937
+ :class: `Connection `.
937
938
This method causes the database connection to disconnect from database
938
939
*name *, and reopen *name * as an in-memory database based on the
939
940
serialization contained in *data *. Deserialization will raise
@@ -1013,20 +1014,20 @@ Cursor Objects
1013
1014
1014
1015
.. method :: fetchone()
1015
1016
1016
- Fetches the next row of a query result set, returning a single sequence,
1017
- or :const: `None ` when no more data is available.
1017
+ Fetch the next row of a query result set as a :class: ` tuple `.
1018
+ Return :const: `None ` if no more data is available.
1018
1019
1019
1020
1020
1021
.. method :: fetchmany(size=cursor.arraysize)
1021
1022
1022
- Fetches the next set of rows of a query result, returning a list. An empty
1023
- list is returned when no more rows are available.
1023
+ Fetch the next set of rows of a query result as a :class: ` list `.
1024
+ Return an empty list if no more rows are available.
1024
1025
1025
1026
The number of rows to fetch per call is specified by the *size * parameter.
1026
- If it is not given, the cursor's arraysize determines the number of rows
1027
- to be fetched. The method should try to fetch as many rows as indicated by
1028
- the size parameter. If this is not possible due to the specified number of
1029
- rows not being available, fewer rows may be returned.
1027
+ If * size * is not given, :attr: ` arraysize ` determines the number of rows
1028
+ to be fetched.
1029
+ If fewer than * size * rows are available,
1030
+ as many rows as are available are returned.
1030
1031
1031
1032
Note there are performance considerations involved with the *size * parameter.
1032
1033
For optimal performance, it is usually best to use the arraysize attribute.
@@ -1035,9 +1036,10 @@ Cursor Objects
1035
1036
1036
1037
.. method :: fetchall()
1037
1038
1038
- Fetches all (remaining) rows of a query result, returning a list. Note that
1039
- the cursor's arraysize attribute can affect the performance of this operation.
1040
- An empty list is returned when no rows are available.
1039
+ Fetch all (remaining) rows of a query result as a :class: `list `.
1040
+ Return an empty list if no rows are available.
1041
+ Note that the :attr: `arraysize ` attribute can affect the performance of
1042
+ this operation.
1041
1043
1042
1044
.. method :: close()
1043
1045
@@ -1064,7 +1066,7 @@ Cursor Objects
1064
1066
1065
1067
.. attribute :: lastrowid
1066
1068
1067
- This read -only attribute provides the row id of the last inserted row. It
1069
+ Read -only attribute that provides the row id of the last inserted row. It
1068
1070
is only updated after successful ``INSERT `` or ``REPLACE `` statements
1069
1071
using the :meth: `execute ` method. For other statements, after
1070
1072
:meth: `executemany ` or :meth: `executescript `, or if the insertion failed,
@@ -1084,16 +1086,16 @@ Cursor Objects
1084
1086
1085
1087
.. attribute :: description
1086
1088
1087
- This read -only attribute provides the column names of the last query. To
1089
+ Read -only attribute that provides the column names of the last query. To
1088
1090
remain compatible with the Python DB API, it returns a 7-tuple for each
1089
1091
column where the last six items of each tuple are :const: `None `.
1090
1092
1091
1093
It is set for ``SELECT `` statements without any matching rows as well.
1092
1094
1093
1095
.. attribute :: connection
1094
1096
1095
- This read -only attribute provides the SQLite database :class: `Connection `
1096
- used by the :class: ` Cursor ` object . A :class: `Cursor ` object created by
1097
+ Read -only attribute that provides the SQLite database :class: `Connection `
1098
+ belonging to the cursor . A :class: `Cursor ` object created by
1097
1099
calling :meth: `con.cursor() <Connection.cursor> ` will have a
1098
1100
:attr: `connection ` attribute that refers to *con *::
1099
1101
@@ -1121,7 +1123,8 @@ Row Objects
1121
1123
1122
1124
.. method :: keys
1123
1125
1124
- This method returns a list of column names. Immediately after a query,
1126
+ Return a :class: `list ` of column names as :class: `strings <str> `.
1127
+ Immediately after a query,
1125
1128
it is the first member of each tuple in :attr: `Cursor.description `.
1126
1129
1127
1130
.. versionchanged :: 3.5
0 commit comments