datus-sqlalchemy
Base SQLAlchemy connector for Datus database adapters.
Overview
datus-sqlalchemy provides a common SQLAlchemy-based connector foundation for database adapters in the Datus ecosystem. It is not a standalone database adapter but serves as a shared base class for adapters like MySQL, PostgreSQL, and other SQLAlchemy-compatible databases.
Features
- SQLAlchemy engine and connection management
- Unified error handling and exception mapping
- Support for multiple result formats (pandas, arrow, csv, list)
- Connection pooling and lifecycle management
- Streaming query execution
- Metadata retrieval methods
Installation
pip install datus-sqlalchemy
Note: This package is typically installed as a dependency of specific database adapters (e.g., datus-mysql).
Usage
This package is intended to be used as a base class for database adapters:
from datus_sqlalchemy import SQLAlchemyConnector
class MyDatabaseConnector(SQLAlchemyConnector):
def __init__(self, host, port, user, password, database):
connection_string = f"mydb://{user}:{password}@{host}:{port}/{database}"
super().__init__(connection_string, dialect="mydb")
Optional connection hooks
configure_connection(connect_args=..., url_defaults=..., connection_parameters=..., credential_version=..., connection_cleanup=..., connection_validator=...)
adds static driver parameters and an optional dynamic provider. Each new engine,
including PostgreSQL's per-database engines, uses the same _create_engine path.
url_defaults fills missing URL query options before dialect translation. Existing
URL options win, preserving subclass-normalized CA paths. Use this for PostgreSQL
TLS and timeout options that a dialect must translate for its selected DBAPI.
Static connect_args override translated URL options; the dynamic provider
overrides both at every physical connection through do_connect. No new abstract
methods are required.
The optional credential_version(force: bool) callback runs before engine lookup.
A changed version disposes owned pools; refresh_credentials() forces this check.
Replacing hook configuration also disposes pools and must happen between operations.
The optional connection_cleanup() callback releases provider resources when pools
are closed or replaced. It must tolerate repeated calls and later reconnection.
The optional connection_validator(dbapi_connection) runs before each checkout.
It can raise SQLAlchemy DisconnectionError to reject a stale server role and use
the pool's bounded physical-connection retries before application SQL is sent.
This does not replay application statements.
Existing adapters that do not configure these hooks retain their creation behavior.
See Aurora for the MySQL/PostgreSQL implementation and tests.
Requirements
- Python >= 3.12
- datus-agent >= 0.2.2
- sqlalchemy >= 2.0.23
- pyarrow >= 14.0.0
- pandas >= 2.1.4
License
Apache License 2.0
Related Packages
datus-mysql- MySQL database adapterdatus-starrocks- StarRocks database adapterdatus-snowflake- Snowflake database adapter (uses native connector)
Metadata
Release files for datus-sqlalchemy 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datus_sqlalchemy-0.1.12.tar.gz | 31.8 kB | Without provenance | Details for datus_sqlalchemy-0.1.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datus_sqlalchemy-0.1.12-py3-none-any.whl | Python 3 | none | any | Details for datus_sqlalchemy-0.1.12-py3-none-any.whl |
Total release size: 52.5 kB
Release files / datus_sqlalchemy-0.1.12.tar.gz
| Download URL | datus_sqlalchemy-0.1.12.tar.gz |
|---|---|
| Size | 31.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
299c74f3aa2aa44823a2a9f2a4c740a5b49ed4d0237a890a9b7fc5af957a6475
|
|
BLAKE2b-256 checksum How to use checksums |
a7f58c616b97afd274ef134c523316435a064f0fe0b6d0a4eb5884ea7479644c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / datus_sqlalchemy-0.1.12-py3-none-any.whl
| Download URL | datus_sqlalchemy-0.1.12-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e5ada25d10755757b3292cf24c6501354dadfa9334da34d89ac5327e70bd668
|
|
BLAKE2b-256 checksum How to use checksums |
c628668adbfe768a60a86045baacca38898e854cefd271bd6ec89c54d9d3a402
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for datus-sqlalchemy 0.1.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.