diff --git a/docs/plugins.rst b/docs/plugins.rst index 6357ad9..99588ee 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -140,9 +140,7 @@ As a special niche feature, if your plugin needs to import some files and then a prepare_connection(conn) ~~~~~~~~~~~~~~~~~~~~~~~~ -This hook is called when a new SQLite database connection is created. You can -use it to `register custom SQL functions `_, -aggregates and collations. For example: +This hook is called when a new SQLite database connection is created. You can use it to `register custom SQL functions `_, aggregates and collations. For example: .. code-block:: python @@ -154,8 +152,7 @@ aggregates and collations. For example: "hello", 1, lambda name: f"Hello, {name}!" ) -This registers a SQL function called ``hello`` which takes a single -argument and can be called like this: +This registers a SQL function called ``hello`` which takes a single argument and can be called like this: .. code-block:: sql diff --git a/docs/python-api.rst b/docs/python-api.rst index 4b6b43e..e9eb371 100644 --- a/docs/python-api.rst +++ b/docs/python-api.rst @@ -148,21 +148,11 @@ The ``Database`` object also works as a context manager, which will automaticall db["my_table"].insert({"name": "Example"}) # Connection is automatically closed here -Exiting the block is equivalent to calling ``db.close()``: the connection is -closed and any transaction still open at that point is rolled back. This -matches SQLite's own behavior when a connection closes. +Exiting the block is equivalent to calling ``db.close()``: the connection is closed and any transaction still open at that point is rolled back. This matches SQLite's own behavior when a connection closes. -This rarely matters in practice. Everything that writes to the database - -including raw ``db.execute()`` statements - commits automatically, so a -transaction can only be open here if you explicitly started one with -``db.begin()`` and have not yet committed it. In that case the decision to -commit stays with you: committing automatically on exit could silently -persist half-finished work, for example if your code returned early from the -block. Call ``db.commit()`` when the work is complete. +This rarely matters in practice. Everything that writes to the database - including raw ``db.execute()`` statements - commits automatically, so a transaction can only be open here if you explicitly started one with ``db.begin()`` and have not yet committed it. In that case the decision to commit stays with you: committing automatically on exit could silently persist half-finished work, for example if your code returned early from the block. Call ``db.commit()`` when the work is complete. -Note this differs from the ``sqlite3.Connection`` context manager in the -standard library, which commits on success but does not close the connection. -See :ref:`python_api_transactions` for the full transaction model. +Note this differs from the ``sqlite3.Connection`` context manager in the standard library, which commits on success but does not close the connection. See :ref:`python_api_transactions` for the full transaction model. .. _python_api_attach: