Skip to content

Document sqlite3.connect() as implicitly opening transactions in the new PEP-249 manual commit mode #99824

Closed
@geryogam

Description

@geryogam

Documentation

In sqlite3, @malemburg specified that connect(), commit(), and rollback() implicitly open transactions in the new PEP-249 manual commit mode implemented in PR #93823:

If this is set to False, the module could then implement the
correct way of handling transactions, which means:

a) start a new transaction when the connection is opened
b) start a new transaction after .commit() and .rollback()
c) don't start new transactions anywhere else
d) run an implicit .rollback() when the connection closes

So I expect to see that information clearly documented.

Yet the PR documented it only for commit() and rollback() (item b), not for connect() (item a):

* :mod:`!sqlite3` ensures that a transaction is always open,
  so :meth:`Connection.commit` and :meth:`Connection.rollback`
  will implicitly open a new transaction immediately after closing
  the pending one.

To me it is important to document it also for connect() rather than relying on user’s deduction, which is not obvious at all since for instance in legacy manual commit mode, sqlite3 does not implicitly open transactions when connect() is called but when execute() is called on a DML statement.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions