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.
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datus_tidb-0.1.0.tar.gz.
File metadata
- Download URL: datus_tidb-0.1.0.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fae605fe65ce364c1496ba24a61eae7b8ff037c59728f76121eb1c6fca8041e
|
|
| MD5 |
f438f0f586249a7eef260372bd072543
|
|
| BLAKE2b-256 |
84a6f093abb76a09350ebd5326a77464568ca518cd079b756a8cf0ec19d224f7
|
File details
Details for the file datus_tidb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: datus_tidb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8596281ad289661a9f1154dd3a9dd6acb19301c829a44092145e369bbd5bacfe
|
|
| MD5 |
c85e69842ef40af45c48db4c18d35442
|
|
| BLAKE2b-256 |
ad4270f8b8b3647640cc74756bda6904632d00f968c269737fec4bdc74da327b
|