GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve docs/docstrings of sqlite3 commit()/rollback() and close() · Issue #93925 · python/cpython

Improve docs/docstrings of sqlite3 commit()/rollback() and close() #93925

New issue
Copy link
New issue
Copy link
Closed
#93926
Closed
Improve docs/docstrings of sqlite3 commit()/rollback() and close()#93925
#93926
Copy link
Assignees
erlend-aasland
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-sqlite3

Description

@erlend-aasland
erlend-aasland
opened on Jun 17, 2022
Issue body actions

Originally posted by @mwichmann in #93890 (comment):

So (real question, no criticism): does that mean there ought to be more detail in the commit/rollback descriptions, rather than the context manager bit?

The wording of the docs and docstrings for the commit, rollback, and close connection methods can be improved, in order to provide more clarity around transaction handling.

Fixed with:

  • gh-93925: Improve doc clarity of sqlite3 commit/rollback, and close #93926
  • [3.11] gh-93925: Improve clarity of sqlite3 commit/rollback, and close docs (GH-93926) #94010
  • [3.10] gh-93925: Improve clarity of sqlite3 commit/rollback, and close docs (GH-93926) #94011

Activity

  1. erlend-aasland
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    topic-sqlite3
    on Jun 17, 2022
  2. erlend-aasland
    added this to sqlite3 issueson Jun 17, 2022
  3. erlend-aasland
    moved this to In Progress in sqlite3 issueson Jun 17, 2022
  4. erlend-aasland
    self-assigned this
    on Jun 17, 2022
  5. erlend-aasland
    added a commit that references this issue on Jun 17, 2022

    pythongh-93925: Improve doc clarity of sqlite3 commit/rollback, and c…

    ffefedf
  6. erlend-aasland
    linked a pull request that will close this issuegh-93925: Improve doc clarity of sqlite3 commit/rollback, and close #93926on Jun 17, 2022
  7. erlend-aasland commented on Jun 17, 2022

    @erlend-aasland
    erlend-aasland
    on Jun 17, 2022
    ContributorAuthor
    More actions

    PEP-249 says this about commit (the first sentence is of importance here):

    Commit any pending transaction to the database.
    Note that if the database supports an auto-commit feature, this must be initially off. An interface method may be provided to turn it back on.
    Database modules that do not support transactions should implement this method with void functionality.

    ... and this about rollback (the second sentence is of importance here):

    This method is optional since not all databases provide transaction support. [3]
    In case a database does provide transactions this method causes the database to roll back to the start of any pending transaction. Closing a connection without committing the changes first will cause an implicit rollback to be performed.

    Note, the proposed autocommit attribute will fix the auto-commit issues of sqlite3. That proposed feature will also fix the last sentence of the rollback specification; per now, an implicit rollback is not performed on close. No transaction control is performed on close.

  8. erlend-aasland commented on Jun 17, 2022

    @erlend-aasland
    erlend-aasland
    on Jun 17, 2022
    ContributorAuthor
    More actions

    PEP-249 says this about close:

    Close the connection now (rather than whenever .del() is called).
    The connection will be unusable from this point forward; an Error (or subclass) exception will be raised if any operation is attempted with the connection. The same applies to all cursor objects trying to use the connection. Note that closing a connection without committing the changes first will cause an implicit rollback to be performed.

    We raise ProgrammingError if any operation is attempted with closed connections:

    cpython/Modules/_sqlite/connection.c

    Lines 504 to 520 in e37a158

    int pysqlite_check_connection(pysqlite_Connection* con)
    {
    if (!con->initialized) {
    pysqlite_state *state = pysqlite_get_state_by_type(Py_TYPE(con));
    PyErr_SetString(state->ProgrammingError,
    "Base Connection.__init__ not called.");
    return 0;
    }
    if (!con->db) {
    PyErr_SetString(con->state->ProgrammingError,
    "Cannot operate on a closed database.");
    return 0;
    } else {
    return 1;
    }
    }

    No implicit rollback is performed at the moment. This will change in the future with the autocommit attribute.

  9. erlend-aasland
    closed this as completedin #93926on Jun 19, 2022
  10. Repository owner moved this from In Progress to Done in sqlite3 issueson Jun 19, 2022
  11. erlend-aasland
    added a commit that references this issue on Jun 19, 2022

    gh-93925: Improve clarity of sqlite3 commit/rollback, and close docs (#…

    6446592
  12. miss-islington
    added a commit that references this issue on Jun 19, 2022

    pythongh-93925: Improve clarity of sqlite3 commit/rollback, and close…

    c16f5d6
  13. erlend-aasland
    added 2 commits that reference this issue on Jun 19, 2022

    [3.10] pythongh-93925: Improve clarity of sqlite3 commit/rollback, an…

    5097a8f

    [3.10] gh-93925: Improve clarity of sqlite3 commit/rollback, and clos…

    c4440e6
  14. miss-islington
    added a commit that references this issue on Jun 19, 2022

    gh-93925: Improve clarity of sqlite3 commit/rollback, and close docs (G…

    8b068c4
  15. erlend-aasland commented on Jun 19, 2022

    @erlend-aasland
    erlend-aasland
    on Jun 19, 2022
    ContributorAuthor
    More actions

    Fixed with:

    • gh-93925: Improve doc clarity of sqlite3 commit/rollback, and close #93926
    • [3.11] gh-93925: Improve clarity of sqlite3 commit/rollback, and close docs (GH-93926) #94010
    • [3.10] gh-93925: Improve clarity of sqlite3 commit/rollback, and close docs (GH-93926) #94011
  16. serhiy-storchaka
    added a commit that references this issue on Jun 26, 2022

    Revert 30935 defer bpo45162 to 312 (#94285)

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

Metadata

Metadata

Assignees

  • @erlend-aasland
    erlend-aasland

Labels

docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-sqlite3

Projects

  • sqlite3 issues
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.