@@ -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
@@ -351,6 +352,7 @@ Module functions and constants
351
352
352
353
.. function :: enable_callback_tracebacks(flag, /)
353
354
355
+ Enable or disable callback tracebacks.
354
356
By default you will not get any tracebacks in user-defined functions,
355
357
aggregates, converters, authorizer callbacks etc. If you want to debug them,
356
358
you can call this function with *flag * set to ``True ``. Afterwards, you will
@@ -392,6 +394,7 @@ Connection Objects
392
394
393
395
.. method :: cursor(factory=Cursor)
394
396
397
+ Create and return a :class: `Cursor ` object.
395
398
The cursor method accepts a single optional parameter *factory *. If
396
399
supplied, this must be a callable returning an instance of :class: `Cursor `
397
400
or its subclasses.
@@ -518,9 +521,9 @@ Connection Objects
518
521
519
522
.. method :: interrupt()
520
523
521
- You can call this method from a different thread to abort any queries that might
522
- be executing on the connection. The query will then abort and the caller will
523
- get an exception.
524
+ Call this method from a different thread to abort any queries that might
525
+ be executing on the connection.
526
+ Aborted queries will raise an exception.
524
527
525
528
526
529
.. method :: set_authorizer(authorizer_callback)
@@ -620,10 +623,9 @@ Connection Objects
620
623
621
624
.. attribute :: row_factory
622
625
623
- You can change this attribute to a callable that accepts the cursor and the
624
- original row as a tuple and will return the real result row. This way, you can
625
- implement more advanced ways of returning results, such as returning an object
626
- that can also access columns by name.
626
+ A callable that accepts two arguments,
627
+ a :class: `Cursor ` object and the raw row results as a :class: `tuple `,
628
+ and returns a custom object representing an SQLite row.
627
629
628
630
Example:
629
631
@@ -641,31 +643,28 @@ Connection Objects
641
643
642
644
.. attribute :: text_factory
643
645
644
- Using this attribute you can control what objects are returned for the ``TEXT ``
645
- data type. By default, this attribute is set to :class: `str ` and the
646
- :mod: `sqlite3 ` module will return :class: `str ` objects for ``TEXT ``.
647
- If you want to return :class: `bytes ` instead, you can set it to :class: `bytes `.
646
+ A callable that accepts a :class: `bytes ` parameter and returns a text
647
+ representation of it.
648
+ The callable is invoked for SQLite values with the ``TEXT `` data type.
649
+ By default, this attribute is set to :class: `str `.
650
+ If you want to return ``bytes `` instead, set *text_factory * to ``bytes ``.
648
651
649
- You can also set it to any other callable that accepts a single bytestring
650
- parameter and returns the resulting object.
651
-
652
- See the following example code for illustration:
652
+ Example:
653
653
654
654
.. literalinclude :: ../includes/sqlite3/text_factory.py
655
655
656
656
657
657
.. attribute :: total_changes
658
658
659
- Returns the total number of database rows that have been modified, inserted, or
659
+ Return the total number of database rows that have been modified, inserted, or
660
660
deleted since the database connection was opened.
661
661
662
662
663
663
.. method :: iterdump
664
664
665
- Returns an iterator to dump the database in an SQL text format. Useful when
666
- saving an in-memory database for later restoration. This function provides
667
- the same capabilities as the :kbd: `.dump ` command in the :program: `sqlite3 `
668
- shell.
665
+ Return an :term: `iterator ` to dump the database as SQL source code.
666
+ Useful when saving an in-memory database for later restoration.
667
+ Similar to the ``.dump `` command in the :program: `sqlite3 ` shell.
669
668
670
669
Example::
671
670
@@ -806,20 +805,20 @@ Cursor Objects
806
805
807
806
.. method :: fetchone()
808
807
809
- Fetches the next row of a query result set, returning a single sequence,
810
- or :const: `None ` when no more data is available.
808
+ Fetch the next row of a query result set as a :class: ` tuple `.
809
+ Return :const: `None ` if no more data is available.
811
810
812
811
813
812
.. method :: fetchmany(size=cursor.arraysize)
814
813
815
- Fetches the next set of rows of a query result, returning a list. An empty
816
- list is returned when no more rows are available.
814
+ Fetch the next set of rows of a query result as a :class: ` list `.
815
+ Return an empty list if no more rows are available.
817
816
818
817
The number of rows to fetch per call is specified by the *size * parameter.
819
- If it is not given, the cursor's arraysize determines the number of rows
820
- to be fetched. The method should try to fetch as many rows as indicated by
821
- the size parameter. If this is not possible due to the specified number of
822
- rows not being available, fewer rows may be returned.
818
+ If * size * is not given, :attr: ` arraysize ` determines the number of rows
819
+ to be fetched.
820
+ If fewer than * size * rows are available,
821
+ as many rows as are available are returned.
823
822
824
823
Note there are performance considerations involved with the *size * parameter.
825
824
For optimal performance, it is usually best to use the arraysize attribute.
@@ -828,9 +827,10 @@ Cursor Objects
828
827
829
828
.. method :: fetchall()
830
829
831
- Fetches all (remaining) rows of a query result, returning a list. Note that
832
- the cursor's arraysize attribute can affect the performance of this operation.
833
- An empty list is returned when no rows are available.
830
+ Fetch all (remaining) rows of a query result as a :class: `list `.
831
+ Return an empty list if no rows are available.
832
+ Note that the :attr: `arraysize ` attribute can affect the performance of
833
+ this operation.
834
834
835
835
.. method :: close()
836
836
@@ -857,7 +857,7 @@ Cursor Objects
857
857
858
858
.. attribute :: lastrowid
859
859
860
- This read -only attribute provides the row id of the last inserted row. It
860
+ Read -only attribute that provides the row id of the last inserted row. It
861
861
is only updated after successful ``INSERT `` or ``REPLACE `` statements
862
862
using the :meth: `execute ` method. For other statements, after
863
863
:meth: `executemany ` or :meth: `executescript `, or if the insertion failed,
@@ -877,16 +877,16 @@ Cursor Objects
877
877
878
878
.. attribute :: description
879
879
880
- This read -only attribute provides the column names of the last query. To
880
+ Read -only attribute that provides the column names of the last query. To
881
881
remain compatible with the Python DB API, it returns a 7-tuple for each
882
882
column where the last six items of each tuple are :const: `None `.
883
883
884
884
It is set for ``SELECT `` statements without any matching rows as well.
885
885
886
886
.. attribute :: connection
887
887
888
- This read -only attribute provides the SQLite database :class: `Connection `
889
- used by the :class: ` Cursor ` object . A :class: `Cursor ` object created by
888
+ Read -only attribute that provides the SQLite database :class: `Connection `
889
+ belonging to the cursor . A :class: `Cursor ` object created by
890
890
calling :meth: `con.cursor() <Connection.cursor> ` will have a
891
891
:attr: `connection ` attribute that refers to *con *::
892
892
@@ -914,7 +914,8 @@ Row Objects
914
914
915
915
.. method :: keys
916
916
917
- This method returns a list of column names. Immediately after a query,
917
+ Return a :class: `list ` of column names as :class: `strings <str> `.
918
+ Immediately after a query,
918
919
it is the first member of each tuple in :attr: `Cursor.description `.
919
920
920
921
.. versionchanged :: 3.5
0 commit comments