Skip to content

Fix transaction example in README: transaction() is a context manager#234

Open
dhavalp5415 wants to merge 1 commit into
kennethreitz:masterfrom
dhavalp5415:fix/readme-transaction-example
Open

Fix transaction example in README: transaction() is a context manager#234
dhavalp5415 wants to merge 1 commit into
kennethreitz:masterfrom
dhavalp5415:fix/readme-transaction-example

Conversation

@dhavalp5415

Copy link
Copy Markdown

The README (both .md and .rst) documents transactions as:

t = Database.transaction(); t.commit()

But Database.transaction() is decorated with @contextmanager (records.py lines 335-347): it yields a connection and handles commit/rollback internally. Following the documented example raises:

AttributeError: '_GeneratorContextManager' object has no attribute 'commit'

This PR updates both READMEs to the working usage:

with Database.transaction() as conn:
    ...

HISTORY.rst is left untouched since it records the API as it was at release time.


Found by Doc-Drift Sentinel, an agent that verifies documentation claims against source code. The finding was verified by hand against records.py before this PR was opened.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant