Skip to content

gh-94635: Normalise sqlite3 doc headings #94677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Module functions and constants

.. _sqlite3-connection-objects:

Connection Objects
Connection objects
------------------

.. class:: Connection
Expand Down Expand Up @@ -865,7 +865,7 @@ Connection Objects

.. _sqlite3-cursor-objects:

Cursor Objects
Cursor objects
--------------

.. class:: Cursor
Expand Down Expand Up @@ -1021,7 +1021,7 @@ Cursor Objects

.. _sqlite3-row-objects:

Row Objects
Row objects
-----------

.. class:: Row
Expand Down Expand Up @@ -1087,7 +1087,7 @@ Now we plug :class:`Row` in::

.. _sqlite3-blob-objects:

Blob Objects
Blob objects
------------

.. versionadded:: 3.11
Expand Down Expand Up @@ -1139,7 +1139,7 @@ Blob Objects
end).


PrepareProtocol Objects
PrepareProtocol objects
-----------------------

.. class:: PrepareProtocol
Expand Down Expand Up @@ -1291,8 +1291,8 @@ you can let the :mod:`sqlite3` module convert SQLite types to different Python
types via converters.


Using adapters to store custom Python types in SQLite databases
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How to adapt custom Python types to SQLite values
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

SQLite supports only a limited set of data types natively.
To store custom Python types in SQLite databases, *adapt* them to one of the
Expand All @@ -1309,8 +1309,8 @@ registering custom adapter functions.

.. _sqlite3-conform:

Letting your object adapt itself
""""""""""""""""""""""""""""""""
Let your object adapt itself
""""""""""""""""""""""""""""

Suppose we have a ``Point`` class that represents a pair of coordinates,
``x`` and ``y``, in a Cartesian coordinate system.
Expand All @@ -1323,8 +1323,8 @@ The object passed to *protocol* will be of type :class:`PrepareProtocol`.
.. literalinclude:: ../includes/sqlite3/adapter_point_1.py


Registering an adapter callable
"""""""""""""""""""""""""""""""
Use an adapter callable
"""""""""""""""""""""""

The other possibility is to create a function that converts the Python object
to an SQLite-compatible type.
Expand All @@ -1335,8 +1335,8 @@ This function can then be registered using :func:`register_adapter`.

.. _sqlite3-converters:

Converting SQLite values to custom Python types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How to convert SQLite values to custom Python types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Writing an adapter lets you convert *from* custom Python types *to* SQLite
values.
Expand Down Expand Up @@ -1412,7 +1412,7 @@ The deprecated default adapters and converters consist of:

.. _sqlite3-adapter-converter-recipes:

Adapter and Converter Recipes
Adapter and converter recipes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This section shows recipes for common adapters and converters.
Expand Down Expand Up @@ -1457,8 +1457,8 @@ This section shows recipes for common adapters and converters.

.. _sqlite3-controlling-transactions:

Controlling Transactions
------------------------
Transaction control
-------------------

The ``sqlite3`` module does not adhere to the transaction handling recommended
by :pep:`249`.
Expand Down Expand Up @@ -1528,12 +1528,13 @@ can be found in the `SQLite URI documentation`_.

.. _SQLite URI documentation: https://www.sqlite.org/uri.html

Using :mod:`sqlite3` efficiently
--------------------------------

How to use ``sqlite3`` efficiently
----------------------------------

Using shortcut methods
^^^^^^^^^^^^^^^^^^^^^^

How to use shortcut methods
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Using the nonstandard :meth:`execute`, :meth:`executemany` and
:meth:`executescript` methods of the :class:`Connection` object, your code can
Expand All @@ -1546,8 +1547,8 @@ directly using only a single call on the :class:`Connection` object.
.. literalinclude:: ../includes/sqlite3/shortcut_methods.py


Accessing columns by name instead of by index
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How to access columns by name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

One useful feature of the :mod:`sqlite3` module is the built-in
:class:`sqlite3.Row` class designed to be used as a row factory.
Expand All @@ -1560,8 +1561,8 @@ case-insensitively by name:

.. _sqlite3-connection-context-manager:

Using the connection as a context manager
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How to use a connection as a context manager
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A :class:`Connection` object can be used as a context manager that
automatically commits or rolls back open transactions when leaving the body of
Expand Down