{"id":27453,"library":"tidb-vector","title":"TiDB Vector Python Client","description":"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.","status":"active","version":"0.0.15","language":"python","source_language":"en","source_url":"https://github.com/pingcap/tidb-vector-python","tags":["tidb","vector","similarity-search","database","embeddings"],"install":[{"cmd":"pip install tidb-vector","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for MySQL connection to TiDB","package":"pymysql","optional":false},{"reason":"Used for ORM-style operations","package":"sqlalchemy","optional":true}],"imports":[{"note":"Common mistake: TiDBVectorClient is in integrations submodule","wrong":"from tidb_vector import TiDBVectorClient","symbol":"TiDBVectorClient","correct":"from tidb_vector.integrations import TiDBVectorClient"},{"note":"LangChain integration is also in integrations","wrong":"from tidb_vector import TiDBVectorStore","symbol":"TiDBVectorStore","correct":"from tidb_vector.integrations import TiDBVectorStore"}],"quickstart":{"code":"import os\nfrom tidb_vector.integrations import TiDBVectorClient\n\n# TiDB connection parameters (use env vars for auth)\nhost = os.environ.get('TIDB_HOST', '127.0.0.1')\nport = int(os.environ.get('TIDB_PORT', '4000'))\nuser = os.environ.get('TIDB_USER', 'root')\npassword = os.environ.get('TIDB_PASSWORD', '')\ndatabase = os.environ.get('TIDB_DATABASE', 'test')\n\n# Create vector table and client\nconnection_string = f'mysql+pymysql://{user}:{password}@{host}:{port}/{database}'\nclient = TiDBVectorClient(\n    table_name='vector_demo',\n    connection_string=connection_string,\n    vector_dimension=3,\n    distance_strategy='cosine'\n)\n\n# Insert vectors\nids = ['id1', 'id2', 'id3']\nvectors = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]\nmetadata = [\n    {'text': 'first'},\n    {'text': 'second'},\n    {'text': 'third'}\n]\nclient.insert(ids=ids, vectors=vectors, metadata=metadata)\n\n# Similarity search\nresults = client.query(query_vector=[1.0, 2.0, 3.0], top_k=2)\nfor r in results:\n    print(r.id, r.distance, r.metadata)","lang":"python","description":"Initialize TiDBVectorClient, insert vectors, and perform similarity search."},"warnings":[{"fix":"Ensure TiDB cluster version is 7.1.0 or higher and the vector feature is enabled.","message":"TiDB Vector requires TiDB version >= 7.1.0 with vector support enabled. Earlier versions or standard MySQL will fail.","severity":"breaking","affected_versions":"<0.0.15"},{"fix":"Drop and recreate the table if you need to change distance strategy.","message":"The 'distance_strategy' parameter must match the column definition; changing it after table creation does not alter the stored index.","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'table_name' instead of 'vector_table'.","message":"The 'vector_table' parameter was renamed to 'table_name' in version 0.0.13. Using 'vector_table' may still work but is deprecated.","severity":"deprecated","affected_versions":">=0.0.13"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install tidb-vector'","cause":"Package not installed.","error":"ModuleNotFoundError: No module named 'tidb_vector'"},{"fix":"Set the TIDB_PASSWORD environment variable or provide password in connection string.","cause":"Missing or incorrect password when connecting to TiDB.","error":"pymysql.err.OperationalError: (1045, \"Access denied for user '...'@'...' (using password: NO)\")"},{"fix":"Set auto_create_table=True when creating TiDBVectorClient, or create the table manually before querying.","cause":"Table does not exist; TiDBVectorClient creates it automatically only if 'auto_create_table' is True.","error":"sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1146, \"Table '...' doesn't exist\")"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}