Skip to content
Snippets Groups Projects
Unverified Commit 2361908a authored by Erlend Egeberg Aasland's avatar Erlend Egeberg Aasland Committed by GitHub
Browse files

gh-95273: Normalise sqlite3 reference wording (#95274)

parent 4dd099ba
No related branches found
No related tags found
No related merge requests found
...@@ -149,8 +149,8 @@ Module functions and constants ...@@ -149,8 +149,8 @@ Module functions and constants
.. data:: version .. data:: version
The version number of this module, as a string. This is not the version of Version number of this module as a :class:`string <str>`.
the SQLite library. This is not the version of the SQLite library.
.. deprecated-removed:: 3.12 3.14 .. deprecated-removed:: 3.12 3.14
This constant used to reflect the version number of the ``pysqlite`` This constant used to reflect the version number of the ``pysqlite``
...@@ -160,8 +160,8 @@ Module functions and constants ...@@ -160,8 +160,8 @@ Module functions and constants
.. data:: version_info .. data:: version_info
The version number of this module, as a tuple of integers. This is not the Version number of this module as a :class:`tuple` of :class:`integers <int>`.
version of the SQLite library. This is not the version of the SQLite library.
.. deprecated-removed:: 3.12 3.14 .. deprecated-removed:: 3.12 3.14
This constant used to reflect the version number of the ``pysqlite`` This constant used to reflect the version number of the ``pysqlite``
...@@ -171,12 +171,13 @@ Module functions and constants ...@@ -171,12 +171,13 @@ Module functions and constants
.. data:: sqlite_version .. data:: sqlite_version
The version number of the run-time SQLite library, as a string. Version number of the runtime SQLite library as a :class:`string <str>`.
.. data:: sqlite_version_info .. data:: sqlite_version_info
The version number of the run-time SQLite library, as a tuple of integers. Version number of the runtime SQLite library as a :class:`tuple` of
:class:`integers <int>`.
.. data:: threadsafety .. data:: threadsafety
...@@ -379,6 +380,7 @@ Module functions and constants ...@@ -379,6 +380,7 @@ Module functions and constants
.. function:: enable_callback_tracebacks(flag, /) .. function:: enable_callback_tracebacks(flag, /)
Enable or disable callback tracebacks.
By default you will not get any tracebacks in user-defined functions, By default you will not get any tracebacks in user-defined functions,
aggregates, converters, authorizer callbacks etc. If you want to debug them, aggregates, converters, authorizer callbacks etc. If you want to debug them,
you can call this function with *flag* set to :const:`True`. Afterwards, you you can call this function with *flag* set to :const:`True`. Afterwards, you
...@@ -438,6 +440,7 @@ Connection Objects ...@@ -438,6 +440,7 @@ Connection Objects
.. method:: cursor(factory=Cursor) .. method:: cursor(factory=Cursor)
Create and return a :class:`Cursor` object.
The cursor method accepts a single optional parameter *factory*. If The cursor method accepts a single optional parameter *factory*. If
supplied, this must be a callable returning an instance of :class:`Cursor` supplied, this must be a callable returning an instance of :class:`Cursor`
or its subclasses. or its subclasses.
...@@ -648,9 +651,9 @@ Connection Objects ...@@ -648,9 +651,9 @@ Connection Objects
.. method:: interrupt() .. method:: interrupt()
You can call this method from a different thread to abort any queries that might Call this method from a different thread to abort any queries that might
be executing on the connection. The query will then abort and the caller will be executing on the connection.
get an exception. Aborted queries will raise an exception.
.. method:: set_authorizer(authorizer_callback) .. method:: set_authorizer(authorizer_callback)
...@@ -755,10 +758,9 @@ Connection Objects ...@@ -755,10 +758,9 @@ Connection Objects
.. attribute:: row_factory .. attribute:: row_factory
You can change this attribute to a callable that accepts the cursor and the A callable that accepts two arguments,
original row as a tuple and will return the real result row. This way, you can a :class:`Cursor` object and the raw row results as a :class:`tuple`,
implement more advanced ways of returning results, such as returning an object and returns a custom object representing an SQLite row.
that can also access columns by name.
Example: Example:
...@@ -776,31 +778,28 @@ Connection Objects ...@@ -776,31 +778,28 @@ Connection Objects
.. attribute:: text_factory .. attribute:: text_factory
Using this attribute you can control what objects are returned for the ``TEXT`` A callable that accepts a :class:`bytes` parameter and returns a text
data type. By default, this attribute is set to :class:`str` and the representation of it.
:mod:`sqlite3` module will return :class:`str` objects for ``TEXT``. The callable is invoked for SQLite values with the ``TEXT`` data type.
If you want to return :class:`bytes` instead, you can set it to :class:`bytes`. By default, this attribute is set to :class:`str`.
If you want to return ``bytes`` instead, set *text_factory* to ``bytes``.
You can also set it to any other callable that accepts a single bytestring Example:
parameter and returns the resulting object.
See the following example code for illustration:
.. literalinclude:: ../includes/sqlite3/text_factory.py .. literalinclude:: ../includes/sqlite3/text_factory.py
.. attribute:: total_changes .. attribute:: total_changes
Returns the total number of database rows that have been modified, inserted, or Return the total number of database rows that have been modified, inserted, or
deleted since the database connection was opened. deleted since the database connection was opened.
.. method:: iterdump .. method:: iterdump
Returns an iterator to dump the database in an SQL text format. Useful when Return an :term:`iterator` to dump the database as SQL source code.
saving an in-memory database for later restoration. This function provides Useful when saving an in-memory database for later restoration.
the same capabilities as the :kbd:`.dump` command in the :program:`sqlite3` Similar to the ``.dump`` command in the :program:`sqlite3` shell.
shell.
Example:: Example::
...@@ -881,7 +880,7 @@ Connection Objects ...@@ -881,7 +880,7 @@ Connection Objects
.. method:: getlimit(category, /) .. method:: getlimit(category, /)
Get a connection run-time limit. *category* is the limit category to be Get a connection runtime limit. *category* is the limit category to be
queried. queried.
Example, query the maximum length of an SQL statement:: Example, query the maximum length of an SQL statement::
...@@ -896,7 +895,7 @@ Connection Objects ...@@ -896,7 +895,7 @@ Connection Objects
.. method:: setlimit(category, limit, /) .. method:: setlimit(category, limit, /)
Set a connection run-time limit. *category* is the limit category to be Set a connection runtime limit. *category* is the limit category to be
set. *limit* is the new limit. If the new limit is a negative number, the set. *limit* is the new limit. If the new limit is a negative number, the
limit is unchanged. limit is unchanged.
...@@ -915,7 +914,7 @@ Connection Objects ...@@ -915,7 +914,7 @@ Connection Objects
.. method:: serialize(*, name="main") .. method:: serialize(*, name="main")
This method serializes a database into a :class:`bytes` object. For an Serialize a database into a :class:`bytes` object. For an
ordinary on-disk database file, the serialization is just a copy of the ordinary on-disk database file, the serialization is just a copy of the
disk file. For an in-memory database or a "temp" database, the disk file. For an in-memory database or a "temp" database, the
serialization is the same sequence of bytes which would be written to serialization is the same sequence of bytes which would be written to
...@@ -934,6 +933,8 @@ Connection Objects ...@@ -934,6 +933,8 @@ Connection Objects
.. method:: deserialize(data, /, *, name="main") .. method:: deserialize(data, /, *, name="main")
Deserialize a :meth:`serialized <serialize>` database into a
:class:`Connection`.
This method causes the database connection to disconnect from database This method causes the database connection to disconnect from database
*name*, and reopen *name* as an in-memory database based on the *name*, and reopen *name* as an in-memory database based on the
serialization contained in *data*. Deserialization will raise serialization contained in *data*. Deserialization will raise
...@@ -1013,20 +1014,20 @@ Cursor Objects ...@@ -1013,20 +1014,20 @@ Cursor Objects
.. method:: fetchone() .. method:: fetchone()
Fetches the next row of a query result set, returning a single sequence, Fetch the next row of a query result set as a :class:`tuple`.
or :const:`None` when no more data is available. Return :const:`None` if no more data is available.
.. method:: fetchmany(size=cursor.arraysize) .. method:: fetchmany(size=cursor.arraysize)
Fetches the next set of rows of a query result, returning a list. An empty Fetch the next set of rows of a query result as a :class:`list`.
list is returned when no more rows are available. Return an empty list if no more rows are available.
The number of rows to fetch per call is specified by the *size* parameter. The number of rows to fetch per call is specified by the *size* parameter.
If it is not given, the cursor's arraysize determines the number of rows If *size* is not given, :attr:`arraysize` determines the number of rows
to be fetched. The method should try to fetch as many rows as indicated by to be fetched.
the size parameter. If this is not possible due to the specified number of If fewer than *size* rows are available,
rows not being available, fewer rows may be returned. as many rows as are available are returned.
Note there are performance considerations involved with the *size* parameter. Note there are performance considerations involved with the *size* parameter.
For optimal performance, it is usually best to use the arraysize attribute. For optimal performance, it is usually best to use the arraysize attribute.
...@@ -1035,9 +1036,10 @@ Cursor Objects ...@@ -1035,9 +1036,10 @@ Cursor Objects
.. method:: fetchall() .. method:: fetchall()
Fetches all (remaining) rows of a query result, returning a list. Note that Fetch all (remaining) rows of a query result as a :class:`list`.
the cursor's arraysize attribute can affect the performance of this operation. Return an empty list if no rows are available.
An empty list is returned when no rows are available. Note that the :attr:`arraysize` attribute can affect the performance of
this operation.
.. method:: close() .. method:: close()
...@@ -1064,7 +1066,7 @@ Cursor Objects ...@@ -1064,7 +1066,7 @@ Cursor Objects
.. attribute:: lastrowid .. attribute:: lastrowid
This read-only attribute provides the row id of the last inserted row. It Read-only attribute that provides the row id of the last inserted row. It
is only updated after successful ``INSERT`` or ``REPLACE`` statements is only updated after successful ``INSERT`` or ``REPLACE`` statements
using the :meth:`execute` method. For other statements, after using the :meth:`execute` method. For other statements, after
:meth:`executemany` or :meth:`executescript`, or if the insertion failed, :meth:`executemany` or :meth:`executescript`, or if the insertion failed,
...@@ -1084,7 +1086,7 @@ Cursor Objects ...@@ -1084,7 +1086,7 @@ Cursor Objects
.. attribute:: description .. attribute:: description
This read-only attribute provides the column names of the last query. To Read-only attribute that provides the column names of the last query. To
remain compatible with the Python DB API, it returns a 7-tuple for each remain compatible with the Python DB API, it returns a 7-tuple for each
column where the last six items of each tuple are :const:`None`. column where the last six items of each tuple are :const:`None`.
...@@ -1092,8 +1094,8 @@ Cursor Objects ...@@ -1092,8 +1094,8 @@ Cursor Objects
.. attribute:: connection .. attribute:: connection
This read-only attribute provides the SQLite database :class:`Connection` Read-only attribute that provides the SQLite database :class:`Connection`
used by the :class:`Cursor` object. A :class:`Cursor` object created by belonging to the cursor. A :class:`Cursor` object created by
calling :meth:`con.cursor() <Connection.cursor>` will have a calling :meth:`con.cursor() <Connection.cursor>` will have a
:attr:`connection` attribute that refers to *con*:: :attr:`connection` attribute that refers to *con*::
...@@ -1121,7 +1123,8 @@ Row Objects ...@@ -1121,7 +1123,8 @@ Row Objects
.. method:: keys .. method:: keys
This method returns a list of column names. Immediately after a query, Return a :class:`list` of column names as :class:`strings <str>`.
Immediately after a query,
it is the first member of each tuple in :attr:`Cursor.description`. it is the first member of each tuple in :attr:`Cursor.description`.
.. versionchanged:: 3.5 .. versionchanged:: 3.5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment