feat: Implement initial Google Cloud Spanner DB-API 2.0 driver#16157
feat: Implement initial Google Cloud Spanner DB-API 2.0 driver#16157bhatt4982 wants to merge 1 commit intodbapi-driverfrom
Conversation
…ore components and comprehensive unit and system tests.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements the initial version of a Google Cloud Spanner DB-API 2.0 driver. It includes the core modules necessary for interacting with Spanner databases, such as connection and cursor management, transaction handling, and exception mapping. The driver aims to provide a familiar interface for Python developers accustomed to the DB-API 2.0 standard, and includes a suite of unit and system tests to validate its functionality. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces an initial implementation of the Google Cloud Spanner DB-API 2.0 driver. The changes are comprehensive, including the core components like connection and cursor objects, a full suite of DB-API exceptions, and extensive unit and system tests. My review focuses on ensuring adherence to the DB-API specification, improving error handling robustness, and enhancing code maintainability. I've identified a few critical issues related to transaction handling where exceptions are suppressed, as well as some areas for improvement in parameter handling and code style.
| except Exception as e: | ||
| # raise errors.map_spanner_error(e) | ||
| logger.debug(f"Commit failed {e}") |
There was a problem hiding this comment.
According to the DB-API 2.0 (PEP 249) specification, commit() should raise an exception if the operation fails. Currently, exceptions are caught and logged, but not re-raised. This can lead to silent failures in applications. The commented-out raise statement should be restored.
| except Exception as e: | |
| # raise errors.map_spanner_error(e) | |
| logger.debug(f"Commit failed {e}") | |
| except Exception as e: | |
| raise errors.map_spanner_error(e) |
| except Exception as e: | ||
| # raise errors.map_spanner_error(e) | ||
| logger.debug(f"Rollback failed {e}") |
There was a problem hiding this comment.
According to the DB-API 2.0 (PEP 249) specification, rollback() should raise an exception if the operation fails. Currently, exceptions are caught and logged, but not re-raised. This can lead to silent failures in applications. The commented-out raise statement should be restored.
| except Exception as e: | |
| # raise errors.map_spanner_error(e) | |
| logger.debug(f"Rollback failed {e}") | |
| except Exception as e: | |
| raise errors.map_spanner_error(e) |
feat: Implement initial Google Cloud Spanner DB-API 2.0 driver with core components and comprehensive unit and system tests.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #16120 🦕