Skip to main content

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

  • datus-mysql - MySQL database adapter
  • datus-starrocks - StarRocks database adapter
  • datus-snowflake - Snowflake database adapter (uses native connector)

Metadata

Release files for datus-sqlalchemy 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datus-sqlalchemy 0.1.11
File Size Uploaded Provenance Actions
datus_sqlalchemy-0.1.11.tar.gz 32.0 kB Without provenance Details for datus_sqlalchemy-0.1.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datus-sqlalchemy 0.1.11
File Interpreter ABI Platform Actions
datus_sqlalchemy-0.1.11-py3-none-any.whl Python 3 none any Details for datus_sqlalchemy-0.1.11-py3-none-any.whl

Total release size: 52.9 kB

Release files / datus_sqlalchemy-0.1.11.tar.gz

Download URL datus_sqlalchemy-0.1.11.tar.gz
Size 32.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f4440bbe2d17d264ab400d9fa781f5bb2364686f7a7f3ecbf4d042c6da163e0b
BLAKE2b-256 checksum
How to use checksums
2fc1a5b77e4dbe181e8c0314f1b9e1e2b80ae079a08a0ccbbb627ee7e8c852ea
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.11-py3-none-any.whl

Download URL datus_sqlalchemy-0.1.11-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfe49cca373283051aed609d0847913c67abad950489d2b7546331c85dcf2126
BLAKE2b-256 checksum
How to use checksums
028e967d69a8dae9fce274f48396ea8ce14218410409a7ad987ca0e948cf7b84
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.11

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page