Skip to content

Align sqlite3 autocommit transaction handling with CPython #8258

Closed

Description

@teddygood

Feature

RustPython exposes the three Connection.autocommit modes, but autocommit=False does not follow CPython's transaction lifecycle. A connection does not enter a transaction immediately, and commit() and rollback() do not open a new transaction afterward. Closing a connection and running executescript() also do not consistently preserve the selected mode.

CPython keeps a transaction open for autocommit=False, reopens one after commit() or rollback(), rolls back a pending transaction on close, and preserves the behavior of the True, False, and legacy modes in context managers, DML execution, and executescript().

This leaves six tests in Lib/test/test_sqlite3/test_transactions.py marked as expected failures. Invalid autocommit value validation is outside this scope.

Python Documentation or reference to CPython source code

Activity

  1. added
    C-compatA discrepancy between RustPython and CPython
    on Jul 11, 2026
  2. teddygood commented on Jul 11, 2026

    @teddygood
    ContributorAuthor

    take

  3. changed the title [-]Align sqlite3 transaction handling for autocommit=False with CPython[/-] [+]Align sqlite3 autocommit transaction handling with CPython[/+] on Jul 27, 2026
  4. teddygood commented on Jul 27, 2026

    @teddygood
    ContributorAuthor

    I plan to split this work into two pull requests:

    1. The first pull request will align the autocommit=False connection lifecycle by opening a transaction when the connection is created, reopening one after commit() or rollback(), rolling back pending changes on close, and preserving the same behavior in context managers.

    2. The second pull request will address cursor transaction control in execute(), executemany(), and executescript() after additional validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-compatA discrepancy between RustPython and CPythonz-ca-2026Tag to track Contribution Academy 2026

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions