Skip to main content

A CLI tool for migrating data from third-party vector databases to TiDB

Project description

vec2tidb

A CLI tool for migrating vector data from vector databases to TiDB.

Python License

┌──────────────────┐    ┌────────────────┐    ┌────────────┐
│ Vector Database  │───▶│  vec2tidb CLI  │───▶│    TiDB    │
└──────────────────┘    └────────────────┘    └────────────┘

Supported vector databases:

  • Qdrant

Why migrate from vector database to TiDB?

TiDB is an open-source, distributed SQL database for modern AI applications:

  • 🗄️ Unified storage: Store vector embeddings, documents, knowledge graphs, and operational data in a single database to reduce maintenance overhead.
  • 🔍 Native SQL support: Run complex queries with full SQL capabilities, including joins, subqueries, aggregations, and advanced analytics.
  • 📈 Effortless scalability: Scale out horizontally with ease to handle dynamic and growing workloads.
  • 🔒 Strong consistency: Ensure data integrity and reliability with ACID transactions and strong consistency guarantees.

Installation

To install the latest version, you can use the following command:

pip install vec2tidb

Usage

To show all commands, use the following command:

vec2tidb --help

Qdrant Commands

To show all qdrant subcommands, use the following command:

vec2tidb qdrant --help

Command: qdrant migrate

To migrate vectors from Qdrant collection to a new TiDB table, use create mode.

vec2tidb qdrant migrate \
  --qdrant-api-url http://localhost:6333 \
  --qdrant-collection-name test_collection \
  --tidb-database-url mysql+pymysql://root:@localhost:4000/test

To migrate the vectors from Qdrant collection to an existing TiDB table, use update mode.

vec2tidb qdrant migrate \
  --qdrant-api-url http://localhost:6333 \
  --qdrant-collection-name test_collection \
  --tidb-database-url mysql+pymysql://root:@localhost:4000/test \
  --mode update \
  --table-name test_table \
  --id-column id \
  --vector-column vector \
  --payload-column payload

Command Options

Option Description
--mode Migration mode: create (create new table) or update (update existing table by ID). Default: create
--qdrant-api-url Qdrant API endpoint. Default: http://localhost:6333
--qdrant-api-key Qdrant API key (if authentication is enabled)
--qdrant-collection-name Name of the source Qdrant collection (required)
--tidb-database-url TiDB connection string. Default: mysql+pymysql://root:@localhost:4000/test
--table-name Target TiDB table name. Required in update mode; defaults to collection name in create mode
--id-column ID column name in TiDB table. Required in update mode; default: id in create mode
--id-column-type ID column type in TiDB table. Default: BIGINT
--vector-column Vector column name in TiDB table. Required in update mode; default: vector in create mode
--payload-column Payload column name in TiDB table. Optional in update mode; default: payload in create mode
--batch-size Batch size for migration. Default: 100
--workers Number of concurrent workers for migration. Default: 1
--drop-table Drop the target table if it exists (flag)

Environment Variables:

The following options can also be set via environment variables:

Variable Description
QDRANT_API_URL Qdrant API endpoint. Default: http://localhost:6333
QDRANT_API_KEY Qdrant API key (if authentication is enabled)
QDRANT_COLLECTION_NAME Qdrant collection name
TIDB_DATABASE_URL TiDB connection string. Default: mysql+pymysql://root:@localhost:4000/test

For example:

export QDRANT_API_URL="http://localhost:6333"
export QDRANT_API_KEY="your-api-key"
export QDRANT_COLLECTION_NAME="my_collection"
export TIDB_DATABASE_URL="mysql+pymysql://root:@localhost:4000/test"

Command: qdrant load-sample

To load a sample dataset into Qdrant collection.

vec2tidb qdrant load-sample \
  --qdrant-api-url http://localhost:6333 \
  --qdrant-collection-name sample_collection \
  --dataset midlib

Command Options

Option Description
--qdrant-api-url Qdrant API endpoint. Default: http://localhost:6333
--qdrant-api-key Qdrant API key (if authentication is enabled)
--qdrant-collection-name Name of the target Qdrant collection (required)
--dataset Sample dataset to load: midlib, qdrant-docs, prefix-cache. Default: midlib (required)
--snapshot-uri Custom snapshot URI (auto-determined from dataset if not provided)

Command: qdrant benchmark

To run performance benchmarks with different configurations.

vec2tidb qdrant benchmark \
  --qdrant-api-url http://localhost:6333 \
  --qdrant-collection-name test_collection \
  --tidb-database-url mysql+pymysql://root:@localhost:4000/test \
  --dataset midlib \
  --workers 1,2,4 \
  --batch-sizes 100,500

Command Options

Option Description
--qdrant-api-url Qdrant API endpoint. Default: http://localhost:6333
--qdrant-api-key Qdrant API key (if authentication is enabled)
--qdrant-collection-name Name of the source Qdrant collection (required)
--tidb-database-url TiDB connection string. Default: mysql+pymysql://root:@localhost:4000/test
--dataset Auto-load sample dataset: midlib, qdrant-docs, prefix-cache
--snapshot-uri Custom snapshot URI for auto-loading data (overrides --dataset)
--workers Comma-separated list of worker counts to test. Default: 1,2,4,8
--batch-sizes Comma-separated list of batch sizes to test. Default: 100,500,1000
--table-prefix Prefix for benchmark table names. Default: benchmark_test

Development

For development setup and contribution guidelines, see DEVELOPMENT.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vec2tidb-0.0.2.tar.gz (282.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vec2tidb-0.0.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file vec2tidb-0.0.2.tar.gz.

File metadata

  • Download URL: vec2tidb-0.0.2.tar.gz
  • Upload date:
  • Size: 282.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.8

File hashes

Hashes for vec2tidb-0.0.2.tar.gz
Algorithm Hash digest
SHA256 77c6e8b976a30ac3375ff6ac362fea2a68ad613158e90411b88b686d0a2bf540
MD5 787fe4eb5138e147c5ed689ac38ddf7e
BLAKE2b-256 97e8c309cb08c9d077f52bd4d1b04c7bfbba90ce506d94994c973fcb54006031

See more details on using hashes here.

File details

Details for the file vec2tidb-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: vec2tidb-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.8

File hashes

Hashes for vec2tidb-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dafc99f3d6caaa18c15f1509b24b76c08385285de02ea9dd019896006b6d9145
MD5 2793fefcf9ea91b7874a1a6f14224397
BLAKE2b-256 1741ec07277319998c133e15c922518d84a4750a2de87d66b0b393c049ad725d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page