Skip to content
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

Improve clarity of sqlite3 transaction handling docs #94017

Closed
erlend-aasland opened this issue Jun 20, 2022 · 3 comments · Fixed by #94320
Closed

Improve clarity of sqlite3 transaction handling docs #94017

erlend-aasland opened this issue Jun 20, 2022 · 3 comments · Fixed by #94320
Labels
docs Documentation in the Doc dir topic-sqlite3

Comments

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Jun 20, 2022

Documentation

The sqlite3 module docs has a section called Controlling Transactions.

There are some improvement possibilities:

  • The current docs start out by describing the SQLite autocommit mode. This can be confusing to new users, especially since the DB API (PEP-249) describes its own autocommit behaviour. Suggesting to tone down the SQLite autocommit mode and instead focus on what the sqlite3 module does.
  • The docs say that implicit BEGIN statements are issues before DML statements. This is partly true. Implicit BEGIN statements are issued before INSERT, UPDATE, DELETE, and REPLACE statements when executed by execute or executemany, but not by executescript. Other DML statements do not receive such treatment.
  • We should update the docs of the execute, executemany, and executescript cursor methods to briefly mention their transaction control peculiarities.
  • Since SQLite autocommit mode is mentioned, we should note that it is in fact possible to query this (low-level) mode using the in_transaction connection attribute. Such information can help developers debug transaction control problems.
  • Possibly augment the docs of the isolation_level attribute. Currently, the isolation_level property of connection refer to the docs of the isolation_level attribute, which again refer to the Controlling Transactions section. The isolation_level property should have a concise description (reference), and link to the isolation_level attribute. The isolation_level attribute should provide a reference for what it does, and briefly mention expected behaviour. The Controlling Transactions section should provide more background (explanation) to what is happening, and it should briefly mention PEP 249, and the SQLite autocommit mode.
  • Revisit any transaction control examples and possibly turn them into clearer how-to's, or guides.
@CAM-Gerlach
Copy link
Member

the isolation_level property of connection

Just to note, this confused me greatly at first, since I thought it was referring to an isolation_level property (@property) of the Connection class, but what it appears to mean is the isolation_level parameter of the connection function.

@erlend-aasland
Copy link
Contributor Author

Just to note, this confused me greatly at first, since I thought it was referring to an isolation_level property (@Property) of the Connection class, but what it appears to mean is the isolation_level parameter of the connection function.

Sorry 'bout that! I was in a hurry :)

erlend-aasland pushed a commit that referenced this issue Jul 6, 2022
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 6, 2022
…ythonGH-94320)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 760b8cf)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 6, 2022
…ythonGH-94320)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 760b8cf)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
miss-islington added a commit that referenced this issue Jul 6, 2022
)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 760b8cf)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
miss-islington added a commit that referenced this issue Jul 6, 2022
)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
(cherry picked from commit 760b8cf)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-sqlite3
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants