query-writing

द्वारा langchain-ai

सरल SELECT से लेकर जटिल मल्टी-टेबल JOIN, एग्रीगेशन और सबक्वेरी तक SQL क्वेरी लिखता और निष्पादित करता है। उपयोग तब करें जब उपयोगकर्ता डेटाबेस से क्वेरी करने के लिए कहे,…

npx skills add https://github.com/langchain-ai/deepagents --skill query-writing

Query Writing Skill

Workflow for Simple Queries

For straightforward questions about a single table:

  1. Identify the table - Which table has the data?
  2. Get the schema - Use sql_db_schema to see columns
  3. Write the query - SELECT relevant columns with WHERE/LIMIT/ORDER BY
  4. Execute - Run with sql_db_query
  5. Format answer - Present results clearly

Workflow for Complex Queries

For questions requiring multiple tables:

1. Plan Your Approach

Use write_todos to break down the task:

  • Identify all tables needed
  • Map relationships (foreign keys)
  • Plan JOIN structure
  • Determine aggregations

2. Examine Schemas

Use sql_db_schema for EACH table to find join columns and needed fields.

3. Construct Query

  • SELECT - Columns and aggregates
  • FROM/JOIN - Connect tables on FK = PK
  • WHERE - Filters before aggregation
  • GROUP BY - All non-aggregate columns
  • ORDER BY - Sort meaningfully
  • LIMIT - Default 5 rows

4. Validate and Execute

Check all JOINs have conditions, GROUP BY is correct, then run query.

Example: Revenue by Country

SELECT
    c.Country,
    ROUND(SUM(i.Total), 2) as TotalRevenue
FROM Invoice i
INNER JOIN Customer c ON i.CustomerId = c.CustomerId
GROUP BY c.Country
ORDER BY TotalRevenue DESC
LIMIT 5;

Error Recovery

If a query fails or returns unexpected results:

  1. Empty results — Verify column names and WHERE conditions against the schema; check for case sensitivity or NULL values
  2. Syntax error — Re-examine JOINs, GROUP BY completeness, and alias references
  3. Timeout — Add stricter WHERE filters or LIMIT to reduce result set, then refine

Quality Guidelines

  • Query only relevant columns (not SELECT *)
  • Always apply LIMIT (5 default)
  • Use table aliases for clarity
  • For complex queries: use write_todos to plan
  • Never use DML statements (INSERT, UPDATE, DELETE, DROP)

langchain-ai की और Skills

deepagents-thread-inspector
langchain-ai
स्थानीय Deep Agents Code SQLite सत्र भंडार में वार्तालापों का निरीक्षण और व्याख्या करें। LangSmith ट्रेस टूलिंग अनुपलब्ध होने पर फ़ॉलबैक के रूप में उपयोग करें, इसके लिए…
deepagents-python-quickstart
langchain-ai
आधिकारिक क्विकस्टार्ट का पालन करके पायथन में एक न्यूनतम स्थानीय डीप एजेंट तैयार करें, टैविली के बजाय प्रदाता-मूल वेब खोज का उपयोग करें। उपयोग करें जब उपयोगकर्ता चाहता है…
deepagents-typescript-quickstart
langchain-ai
आधिकारिक क्विकस्टार्ट का पालन करके TypeScript में एक न्यूनतम स्थानीय Deep Agent तैयार करें, Tavily के बजाय प्रोवाइडर-नेटिव वेब खोज का उपयोग करें। उपयोग करें जब उपयोगकर्ता…
eval-engineering
langchain-ai
किसी एजेंट रिपॉजिटरी और वैकल्पिक उपयोगकर्ता-प्रदत्त ट्रेस का पुनरावृत्त रूप से निरीक्षण करें, उपयोगकर्ता का साक्षात्कार लें, और एक-एक करके Harbor मूल्यांकन बनाएं, चलाएं, और ऑडिट करें। इसके लिए उपयोग करें…
LangChain RAG Pipeline
langchain-ai
इस कौशल का उपयोग किसी भी पुनर्प्राप्ति-संवर्धित पीढ़ी (RAG) प्रणाली के निर्माण में करें। इसमें दस्तावेज़ लोडर, RecursiveCharacterTextSplitter, एम्बेडिंग (OpenAI),… शामिल हैं।
LangChain Structured Output & HITL
langchain-ai
langchain-structured-output-&-hitl — AI एजेंटों के लिए एक इंस्टॉल करने योग्य कौशल, जो langchain-ai/langchain-skills द्वारा प्रकाशित है।
LangSmith Datasets
langchain-ai
इस कौशल का उपयोग करें जब ट्रेस से मूल्यांकन डेटासेट बनाना हो या LangSmith पर डेटासेट अपलोड करना हो या डेटासेट क्वेरी करना हो। इसमें डेटासेट प्रकार शामिल हैं (final_response,…
langsmith-evaluator
langchain-ai
लैंगस्मिथ के लिए मूल्यांकन पाइपलाइन बनाते समय इस कौशल का आह्वान करें। इसमें तीन मुख्य घटक शामिल हैं: (1) मूल्यांकनकर्ता बनाना - LLM-एक-न्यायाधीश, कस्टम कोड; (2)…