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.13

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.13
File Size Uploaded Provenance Actions
datus_sqlalchemy-0.1.13.tar.gz 33.8 kB Without provenance Details for datus_sqlalchemy-0.1.13.tar.gz

Built distribution (wheel)

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

Total release size: 55.5 kB

Release files / datus_sqlalchemy-0.1.13.tar.gz

Download URL datus_sqlalchemy-0.1.13.tar.gz
Size 33.8 kB
Tags Source
SHA-256 checksum
How to use checksums
292594bc6ec905741009a6ec8f85df04d34868fab4226e682cfc493d07e57820
BLAKE2b-256 checksum
How to use checksums
e0367d54671f83ffbc984cb0416cfa9c837e7461ef3538b29bbda5a28bf7b845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / datus_sqlalchemy-0.1.13-py3-none-any.whl

Download URL datus_sqlalchemy-0.1.13-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
472afd1c2ec304693d72998f031cb204a5ea405201c4e7404f31bc299da8ea85
BLAKE2b-256 checksum
How to use checksums
bd8af6a66111c4b22cb7e3d22511cbae0923562c7363df8576f565805f1bf23a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for datus-sqlalchemy 0.1.13

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