pytidb
8
总安装量
4
周安装量
#34843
全站排名
安装命令
npx skills add https://github.com/pingcap/agent-rules --skill pytidb
Agent 安装分布
gemini-cli
3
claude-code
3
codex
3
opencode
3
github-copilot
2
Skill 文档
PyTiDB (pytidb)
Use this skill to connect to TiDB from Python via pytidb, define tables, and build search / AI features on top.
When to Use This Skill
- You want a Python ORM-like experience on TiDB via
pytidb(built on SQLAlchemy). - You want vector search / full-text search / hybrid search on TiDB with high-level APIs.
- You want runnable starter templates (scripts + small examples) you can adapt.
Need to provision a TiDB Cloud cluster first? Use tidbx (TiDB X) for cluster lifecycle guidance.
Code Generation Rules (Python)
- Never hardcode credentials; use env vars (
.env) and document required variables. - Prefer
python -m venv .venvand pinned deps for reproducibility. - When editing requirements.txt, do not invent pytidb versions, use an unpinned pytidb by default unless the user explicitly requests it and the version has been verified to exist.
- Keep examples minimal and runnable; avoid framework-specific assumptions unless the user asks.
- Use parameterized SQL for any dynamic value (SQL injection safety).
- For interactive environments, avoid âtable already definedâ errors (use
extend_existing/open_table/if rows()==0patterns).
Available Guides
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.
Templates & Scripts
Each template is a complete file you can copy into your project. Choose the smallest one that matches your goal.
Core usage
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 scoring
Image search
templates/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 byimage_search.py)
Custom embeddings
templates/custom_embedding_function.pyâ exampleBaseEmbeddingFunctionimplementation (BGE-M3 via FlagEmbedding)templates/custom_embedding.pyâ uses the custom embedder with auto embedding + vector search
Agent-ish examples
templates/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 usingmemory_lib.pytemplates/text2sql.pyâ interactive Text2SQL (generates SQL via OpenAI; asks before executing)
Scripts
scripts/validate_connection.pyâ quick connection +SELECT 1smoke test (supports params orDATABASE_URL)
Related Skills
tidbxâ provision/manage TiDB Cloud (TiDB X) clusters
Workflow
I will:
- Confirm your TiDB deployment (Cloud Starter vs self-managed) and how you want to connect (params vs
DATABASE_URL). - Help you set env vars, validate the connection, and choose the right path:
- CRUD/table modeling
- vector/full-text/hybrid search (and embedding provider)
- example templates
- Generate the minimal set of files and commands to get you running.