Skip to content

Conversation

@tsuga
Copy link
Contributor

@tsuga tsuga commented Jul 27, 2025

This pull request introduces asynchronous support for the aurora-data-api library, enabling developers to perform non-blocking database operations. Key changes include the addition of an asynchronous client and cursor implementation, updated documentation, and minor refactoring of error handling imports.

This fixes #50

Asynchronous Support

  • New Async Client and Cursor: Added AsyncAuroraDataAPIClient and AsyncAuroraDataAPICursor classes in aurora_data_api/async_.py to provide asynchronous database interaction using aiobotocore. These include methods for executing queries, managing transactions, and handling paginated results.
  • Async Connection Function: Introduced a connect function in aurora_data_api/async_.py to create instances of the async client.

Documentation Updates

  • Async Installation Instructions: Updated README.rst to include installation instructions for async support (pip install aurora-data-api[async]).
  • Async Usage Examples: Added examples for async database operations, including query execution and iteration, to help developers integrate async functionality. [1] [2]

Codebase Refactoring

  • boto3 to botocore: Refactored using botocore instead of boto3 to keep the sync version (with botocore) and async version (with aiobotocore) comparable. This should not cause any issues as this library uses only the raw level API from boto3, which is actually botocore.
  • Error Handling Imports: Refactored imports in aurora_data_api/exceptions.py to align with updated module names (error_codes_mysql and error_codes_postgresql).

@tsuga tsuga changed the title Aiobotocore Async Version Jul 27, 2025
Copy link
Contributor

@kislyuk kislyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good, thanks. What kind of testing have you done? Can you confirm that the tests pass for you with an Aurora cluster?

@tsuga
Copy link
Contributor Author

tsuga commented Jul 27, 2025

This looks pretty good, thanks. What kind of testing have you done? Can you confirm that the tests pass for you with an Aurora cluster?

Thanks for reviewing!
Yes, I've tested the new code with live Aurora Serverless v2 clusters (mysql & pg).

@kislyuk kislyuk merged commit 2d60d0c into cloud-utils:main Aug 1, 2025
1 check failed
@kislyuk
Copy link
Contributor

kislyuk commented Aug 1, 2025

Thank you for your contribution, I will test and release shortly.

kislyuk pushed a commit that referenced this pull request Aug 20, 2025
This pull request follows #51 to introduce several improvements and
updates to the `aurora_data_api` library by:

### Feature Enhancements:
* Changed the `connect` function in async version to `async` function.
Although PEP 249 does not define async specifications, it seems to be
common that the function is async, including sqlalchemy's expectation
([link](https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/ext/asyncio/engine.py#L207))
* Reintroduced and implemented the `TimeFromTicks` function in
`aurora_data_api/base.py` to convert ticks into a `datetime.time`
object.
* Added imports for exception classes in `aurora_data_api/__init__.py`,
making them directly accessible from the top-level module.

### Code Cleanup and Consistency:
* Reorganized imports across files (`aurora_data_api/async_.py`,
`aurora_data_api/sync.py`, `aurora_data_api/base.py`) to improve
readability and removed unused imports. Added `# noqa` comments for
selective imports to suppress linter warnings. This is required to
expose certain elements as per PEP 249.
[[1]](diffhunk://#diff-cfa8ccd793ae4442598cce8935ecde0a8dcb5e0b4818a6ae358ebd4120416768L4-R38)
[[2]](diffhunk://#diff-bd02193473dcd006fd8f5a83881b0490fe387259fdf6fe2df2dabfa509b7a2a0L4-R39)
[[3]](diffhunk://#diff-47197841e264cbaec56838025b342376104f7bb383617f816333b01904fdec68L4-L23)
* Standardized string quoting style (single to double quotes) in
`aurora_data_api/async_.py` for consistency.

### Test Infrastructure:
* Introduced a new `test/base.py` file containing base test classes and
a PEP 249 conformance test mixin for validating compliance with the
Python DB-API 2.0 specification.
* Updated `test/test_async.py` to import and utilize the new base test
classes and conformance tests.

### Minor Adjustments (`ruff format` & `ruff check --fix`):
* Simplified the `extras_require` dictionary in `setup.py` by formatting
it as a single line.
* Adjusted line breaks in logging statements and comments for better
readability in `aurora_data_api/async_.py`.
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.

Async options?

2 participants