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

gh-129928: Rework sqlite3 error helpers #129929

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Feb 10, 2025

Add a private API for raising DB-API compatible exceptions based on the
result code of SQLite C APIs. Some APIs do not store the error indicator
on the database pointer, so we need to be able to deduce the DB-API
compatible exception directly from the error code.

  • rename _pysqlite_seterror() as set_error_from_db()
  • introduce set_error_from_code()

📚 Documentation preview 📚: https://cpython-previews--129929.org.readthedocs.build/

@erlend-aasland erlend-aasland changed the title sqlite/set error gh-129928: Rework sqlite3 error helpers Feb 10, 2025
@erlend-aasland erlend-aasland marked this pull request as draft February 10, 2025 00:54
Add a private API for raising DB-API compatible exceptions based on the
result code of SQLite C APIs. Some APIs do not store the error indicator
on the database pointer, so we need to be able to deduce the DB-API
compatible exception directly from the error code.

- rename _pysqlite_seterror() as set_error_from_db()
- introduce set_error_from_code()
@erlend-aasland
Copy link
Contributor Author

cc. @hashbrowncipher, WDYT?

@hashbrowncipher
Copy link
Contributor

LGTM

@erlend-aasland erlend-aasland marked this pull request as ready for review February 10, 2025 07:06
@erlend-aasland
Copy link
Contributor Author

Thanks for the review, @hashbrowncipher!

@erlend-aasland erlend-aasland enabled auto-merge (squash) February 11, 2025 07:29
@erlend-aasland erlend-aasland linked an issue Feb 11, 2025 that may be closed by this pull request
@erlend-aasland erlend-aasland merged commit 3b366a4 into python:main Feb 11, 2025
41 checks passed
@erlend-aasland erlend-aasland deleted the sqlite/set-error branch February 11, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor sqlite3 error handler
2 participants