skills/pytidb/SKILL.md
PyTiDB (pytidb) setup and usage for TiDB from Python. Covers connecting, table modeling (TableModel), CRUD, raw SQL, transactions, vector/full-text/hybrid search, auto-embedding, custom embedding functions, and reference templates/snippets (vector/hybrid/image) plus agent-oriented examples (RAG/memory/text2sql).
npx skillsauth add pingcap/agenticstore pytidbInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill to connect to TiDB from Python via pytidb, define tables, and build search / AI features on top.
pytidb (built on SQLAlchemy).Need to provision a TiDB Cloud cluster first? Use tidbx (TiDB X) for cluster lifecycle guidance.
.env) and document required variables.python -m venv .venv and pinned deps for reproducibility.extend_existing / open_table / if rows()==0 patterns).Each guide is a self-contained walkthrough with a checklist and phases:
guides/quickstart.md — one-file “connect → create table → insert → vector search”guides/search.md — vector / full-text / hybrid: when to use which, plus gotchasguides/demos.md — examples playbook (vector/hybrid/image)guides/agent-apps.md — agent-ish examples (RAG / memory / text2sql)guides/troubleshooting.md — connection, TLS, embedding, and index/search issuesguides/custom-embedding.md — implement a custom embedding function (example: BGE-M3)I’ll infer your intent (CRUD vs search vs “agent app”), then point you to the smallest guide and template set that gets you running.
Each template is a complete file you can copy into your project. Choose the smallest one that matches your goal.
templates/quickstart.py — minimal end-to-end: connect → create table → insert → vector searchtemplates/crud.py — basic table modeling + CRUD lifecycle (create/truncate/insert/query/update/delete)templates/auto_embedding.py — auto embedding with pluggable providers (env-driven)templates/vector_search.py — vector search example (optional metadata filter + threshold)templates/hybrid_search.py — hybrid search example (FullTextField + vector field) with fused scoringtemplates/image_search.py — image-to-image or text-to-image search (requires multimodal embedding + Pillow)templates/image_search_data_loader.py — loads Oxford Pets dataset into TiDB (used by image_search.py)templates/custom_embedding_function.py — example BaseEmbeddingFunction implementation (BGE-M3 via FlagEmbedding)templates/custom_embedding.py — uses the custom embedder with auto embedding + vector searchtemplates/rag.py — minimal RAG: retrieve via vector search, then generate via local LLM (Ollama via LiteLLM)templates/memory_lib.py — reusable “memory” library (extract facts → store → retrieve)templates/memory.py — CLI memory chat example using memory_lib.pytemplates/text2sql.py — interactive Text2SQL (generates SQL via OpenAI; asks before executing)scripts/validate_connection.py — quick connection + SELECT 1 smoke test (supports params or DATABASE_URL)tidbx — provision/manage TiDB Cloud (TiDB X) clustersI will:
DATABASE_URL).devops
Provision TiDB Cloud Serverless clusters and related resources. Use when creating, deleting, or listing clusters/branches, or managing SQL users via the console.
devops
Guidance for using the TiDB Cloud Serverless Driver (Beta) in Node.js, serverless, and edge environments. Use when connecting to TiDB Cloud Starter/Essential over HTTP with @tidbcloud/serverless, or when integrating with Prisma/Kysely/Drizzle serverless adapters in Vercel/Cloudflare/Netlify/Deno/Bun. Use this skill for serverless driver setup and edge runtime guidance.
tools
Prisma ORM setup and usage for TiDB from Node.js/TypeScript. Covers configuring prisma/schema.prisma (MySQL provider), DATABASE_URL formatting for TiDB Cloud TLS (sslaccept=strict and optional sslcert), migrations (prisma migrate), Prisma Client generation, CRUD patterns, and safe raw SQL ($queryRaw) plus runnable templates.
development
Build and deploy Next.js (App Router) apps that connect to TiDB. Covers Route Handlers (app/api/*/route.ts), Node vs Edge runtime selection for database access, environment variable handling, and production-safe DB patterns on Vercel/serverless. Prefer Prisma/Kysely integration, with optional mysql2 for minimal examples. Includes guides and TypeScript templates.