Skip to main content

datus-tidb

TiDB database adapter for Datus.

TiDB speaks the MySQL wire protocol, so this adapter builds on datus-mysql and overrides only what genuinely differs: the METRICS_SCHEMA system database, the absence of materialized views, TiFlash columnar replicas, and the two DDL clauses TiDB accepts without honouring.

Timeouts

timeout_seconds (default 30, positive seconds) bounds pool checkout and is also the default for PyMySQL connect, read, and write timeouts. Override these independently with connect_timeout_seconds, read_timeout_seconds, and write_timeout_seconds. None inherits the finite default. Long queries may need a larger read timeout. Optional query_timeout_seconds configures the server's SELECT deadline on every physical connection; it defaults to None (preserve server settings). Socket inactivity timeouts are not total query deadlines. See timeout semantics and adapter audit.

Installation

pip install datus-tidb

Configuration

namespace:
  my_tidb:
    type: tidb
    host: 127.0.0.1
    port: 4000          # TiDB's own default; 3306 is a different server
    username: root
    password: ""
    database: analytics
Key Default Notes
host 127.0.0.1
port 4000 TiDB's built-in default (tidb-server -P)
username — Required
password ""
database None Default database
charset utf8mb4
autocommit true
timeout_seconds 30

TLS is not supported yet: the semantic layer's MySQL-wire executor has no TLS either, so accepting the keys here would let a datasource connect for metadata and then fail at query time. TiDB Cloud endpoints that require TLS are therefore out of reach for now.

Usage

from datus_tidb import TiDBConfig, TiDBConnector

connector = TiDBConnector(TiDBConfig(username="root", database="analytics"))
result = connector.execute({"sql_query": "SELECT 1"}, result_format="list")

TiFlash

TiFlash is TiDB's columnar replica engine, granted per table with ALTER TABLE t SET TIFLASH REPLICA 1. It needs nothing from this adapter: replicas are transparent to SQL — the optimizer chooses between row store and columnar on its own — and their state is a plain SELECT * FROM information_schema.TIFLASH_REPLICA, which the packaged SQL skill points the model at.

The skill also tells the model to prefer GROUP BY aggregation over an equivalent aggregate window function: the latter does not run in parallel on TiFlash.

Known TiDB behaviors

Construct Behavior
CHECK constraints Parsed, not enforced unless tidb_enable_check_constraint=ON
FULLTEXT indexes Accepted, then silently dropped; MATCH ... AGAINST is rejected
FULL OUTER JOIN Not supported
JSON_TABLE, LATERAL, CREATE TABLE ... AS SELECT Not supported
CORR, COVAR_* Do not exist
Materialized views Do not exist
Views Read-only
Default collation utf8mb4_bin — case-sensitive, unlike MySQL 8

validate_ddl() flags the first two, which are the ones that fail silently.

Testing

# Unit tests (no database)
pytest datus-tidb/tests/unit -v

# Integration tests (four-container cluster with TiFlash)
docker compose -f datus-tidb/docker-compose.yml up -d --wait
pytest datus-tidb/tests/integration -m integration -v
docker compose -f datus-tidb/docker-compose.yml down -v

The compose file runs PD, TiKV, TiDB and TiFlash rather than the single-container --store=unistore form: unistore starts in about a second but has no TiFlash, so it cannot cover the columnar and MPP paths this adapter exposes.

License

Apache License 2.0

Metadata

Release files for datus-tidb 0.1.1

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-tidb 0.1.1
File Size Uploaded Provenance Actions
datus_tidb-0.1.1.tar.gz 22.1 kB Without provenance Details for datus_tidb-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datus-tidb 0.1.1
File Interpreter ABI Platform Actions
datus_tidb-0.1.1-py3-none-any.whl Python 3 none any Details for datus_tidb-0.1.1-py3-none-any.whl

Total release size: 34.5 kB

Release files / datus_tidb-0.1.1.tar.gz

Download URL datus_tidb-0.1.1.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
55408c4f8aa35ba8d0e5d5c5ce8a4a1cfd93c29f76622ee0a98609bb3822cdd7
BLAKE2b-256 checksum
How to use checksums
19de3efd9dbbf7878da402d93535b37f69279cb45038a67d68d20b3e907243a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / datus_tidb-0.1.1-py3-none-any.whl

Download URL datus_tidb-0.1.1-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3df82449a69324ef08e52382ff407009f1453077eea71d2e4dc5b1218f41f53a
BLAKE2b-256 checksum
How to use checksums
c90c43cb549885cc01fe41a81fcf06057a2a001c3a2261903b0f324ae46968d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for datus-tidb 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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