Registry / vector-search / tidb-vector

tidb-vector

JSON →
library0.0.15pypypiunverified

A Python client for TiDB Vector, enabling vector similarity search and storage with TiDB's vector support. Current version 0.0.15, actively developed with weekly releases.

pip install tidb-vector
INSTALL
IMPORT
SIG · TIDB-VECTOR
T
tidb-vector
vector-searchpythonv0.0.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TiDBVectorClient
from tidb_vector import TiDBVectorClient
from tidb_vector.integrations import TiDBVectorClient

Initialize TiDBVectorClient, insert vectors, and perform similarity search.

import os from tidb_vector.integrations import TiDBVectorClient # TiDB connection parameters (use env vars for auth) host = os.environ.get('TIDB_HOST', '127.0.0.1') port = int(os.environ.get('TIDB_PORT', '4000')) user = os.environ.get('TIDB_USER', 'root') password = os.environ.get('TIDB_PASSWORD', '') database = os.environ.get('TIDB_DATABASE', 'test') # Create vector table and client connection_string = f'mysql+pymysql://{user}:{password}@{host}:{port}/{database}' client = TiDBVectorClient( table_name='vector_demo', connection_string=connection_string, vector_dimension=3, distance_strategy='cosine' ) # Insert vectors ids = ['id1', 'id2', 'id3'] vectors = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]] metadata = [ {'text': 'first'}, {'text': 'second'}, {'text': 'third'} ] client.insert(ids=ids, vectors=vectors, metadata=metadata) # Similarity search results = client.query(query_vector=[1.0, 2.0, 3.0], top_k=2) for r in results: print(r.id, r.distance, r.metadata)
Debug
Known issues
breakingTiDB Vector requires TiDB version >= 7.1.0 with vector support enabled. Earlier versions or standard MySQL will fail.
fix
Ensure TiDB cluster version is 7.1.0 or higher and the vector feature is enabled.
affects: <0.0.15
gotchaThe 'distance_strategy' parameter must match the column definition; changing it after table creation does not alter the stored index.
fix
Drop and recreate the table if you need to change distance strategy.
affects: all
deprecatedThe 'vector_table' parameter was renamed to 'table_name' in version 0.0.13. Using 'vector_table' may still work but is deprecated.
fix
Use 'table_name' instead of 'vector_table'.
affects: >=0.0.13
Upgrade
Version history
0.0.15latest on PyPI · released Jul 15, 2025
Audit
Dependencies
pymysqlrequiredRequired for MySQL connection to TiDB
sqlalchemyoptionalUsed for ORM-style operations
Agent activity
63 hits · last 30 days
node
54
Meta
1
OpenAI (training)
1
Resources
tidb-vector — pip install tidb-vector · libregistry