@@ -139,8 +139,8 @@ Module functions and constants
139
139
140
140
.. data :: version
141
141
142
- The version number of this module, as a string. This is not the version of
143
- the SQLite library.
142
+ Version number of this module as a :class: ` string <str> `.
143
+ This is not the version of the SQLite library.
144
144
145
145
.. deprecated-removed :: 3.12 3.14
146
146
This constant used to reflect the version number of the ``pysqlite ``
@@ -150,8 +150,8 @@ Module functions and constants
150
150
151
151
.. data :: version_info
152
152
153
- The version number of this module, as a tuple of integers. This is not the
154
- version of the SQLite library.
153
+ Version number of this module as a :class: ` tuple ` of :class: ` integers <int> `.
154
+ This is not the version of the SQLite library.
155
155
156
156
.. deprecated-removed :: 3.12 3.14
157
157
This constant used to reflect the version number of the ``pysqlite ``
@@ -161,12 +161,13 @@ Module functions and constants
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 run-time 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 run-time 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 return any object that fit the application programmers need.
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 accept a :class: `bytes ` parameter and return 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 :kbd: `.dump ` command in the :program: `sqlite3 ` shell.
794
793
795
794
Example::
796
795
@@ -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,19 @@ 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 ` when 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 is when 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, fewer rows are returned.
1020
1020
1021
1021
Note there are performance considerations involved with the *size * parameter.
1022
1022
For optimal performance, it is usually best to use the arraysize attribute.
@@ -1025,9 +1025,10 @@ Cursor Objects
1025
1025
1026
1026
.. method :: fetchall()
1027
1027
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.
1028
+ Fetch all (remaining) rows of a query result as a :class: `list `.
1029
+ Return an empty list when no rows are available.
1030
+ Note that the :attr: `arraysize ` attribute can affect the performance of
1031
+ this operation.
1031
1032
1032
1033
.. method :: close()
1033
1034
@@ -1054,7 +1055,7 @@ Cursor Objects
1054
1055
1055
1056
.. attribute :: lastrowid
1056
1057
1057
- This read -only attribute provides the row id of the last inserted row. It
1058
+ Read -only attribute that provides the row id of the last inserted row. It
1058
1059
is only updated after successful ``INSERT `` or ``REPLACE `` statements
1059
1060
using the :meth: `execute ` method. For other statements, after
1060
1061
:meth: `executemany ` or :meth: `executescript `, or if the insertion failed,
@@ -1074,16 +1075,16 @@ Cursor Objects
1074
1075
1075
1076
.. attribute :: description
1076
1077
1077
- This read -only attribute provides the column names of the last query. To
1078
+ Read -only attribute that provides the column names of the last query. To
1078
1079
remain compatible with the Python DB API, it returns a 7-tuple for each
1079
1080
column where the last six items of each tuple are :const: `None `.
1080
1081
1081
1082
It is set for ``SELECT `` statements without any matching rows as well.
1082
1083
1083
1084
.. attribute :: connection
1084
1085
1085
- This read -only attribute provides the SQLite database :class: `Connection `
1086
- used by the :class: ` Cursor ` object . A :class: `Cursor ` object created by
1086
+ Read -only attribute that provides the SQLite database :class: `Connection `
1087
+ belonging to the cursor . A :class: `Cursor ` object created by
1087
1088
calling :meth: `con.cursor() <Connection.cursor> ` will have a
1088
1089
:attr: `connection ` attribute that refers to *con *::
1089
1090
@@ -1111,7 +1112,8 @@ Row Objects
1111
1112
1112
1113
.. method :: keys
1113
1114
1114
- This method returns a list of column names. Immediately after a query,
1115
+ Return a :class: `list ` of column names as :class: `strings <str> `.
1116
+ Immediately after a query,
1115
1117
it is the first member of each tuple in :attr: `Cursor.description `.
1116
1118
1117
1119
.. versionchanged :: 3.5
0 commit comments