sql-analysis
Operate ai-data-science-team SQL database querying, metadata inspection, read-only SQL safety, and SQLDatabaseAgent workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- sql-analysis
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Operate ai-data-science-team SQL database querying, metadata inspection, read-only SQL safety, and SQLDatabaseAgent workflows.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md6.7 KB
- 参考文档references/sql-safety-and-metadata.md5.5 KB
- 参考文档references/troubleshooting.md5.9 KB
- 参考文档references/workflows.md6.2 KB
- 脚本scripts/smoke_sql_safety.py8.7 KB
03 SKILL.md 正文
SQL Analysis
Use this sub-skill when the task is to query a SQL database with ai-data-science-team, summarize database metadata, validate generated SQL for read-only safety, or operate SQLDatabaseAgent / make_sql_database_agent directly.
Route here for
- SQLAlchemy engine or connection setup for a database that will be queried by
SQLDatabaseAgent. - Metadata summaries with
ai_data_science_team.tools.sql.get_database_metadata. - Natural-language-to-SQL workflows where the caller supplies an already configured LLM object.
- Checking that generated SQL is read-only with the package's
_validate_sqlimplementation or the bundled smoke script. - Interpreting
SQLDatabaseAgentresponse fields such assql_query_code,data_sql,sql_database_function, andsql_database_error.
Route away
- For
SQLDataAnalystcomposition, supervisor workflows, or Streamlit app launching, use the siblingmultiagent-and-app-workflowssub-skill. - For charting or Plotly visualization of SQL results, use the sibling
dataframe-code-agentssub-skill after converting the SQL result dict to a DataFrame. - For file loading, direct DataFrame EDA, or optional EDA reports, use the sibling
data-access-and-edasub-skill. - For H2O AutoML, model evaluation, or MLflow tools, use the sibling
modeling-and-mlflowsub-skill.
Safe operating defaults
- Use a read-only database account or a disposable database copy whenever possible.
- Keep
safe_mode=Trueunless the user explicitly accepts the risk and the database account itself is read-only. - Start with
n_samples=1for metadata; increase only when sample values are necessary and safe to share. - Do not launch Streamlit apps, call external LLM providers, download data, or write generated SQL logs unless the user asked for that side effect.
- Redact hostnames, database names, usernames, and connection URLs before sharing metadata or logs outside the local task.
Core workflow
import pandas as pd
import sqlalchemy as sql
from ai_data_science_team.agents import SQLDatabaseAgent
engine = sql.create_engine("sqlite:///example.db")
llm = ... # caller-provided LangChain-compatible chat model
agent = SQLDatabaseAgent(
model=llm,
connection=engine,
n_samples=1,
safe_mode=True,
log=False,
bypass_recommended_steps=True,
bypass_explain_code=True,
)
agent.invoke_agent("Return sales by month for 2024", max_retries=3, retry_count=0)
query = agent.get_sql_query_code()
data = agent.get_data_sql()
frame = pd.DataFrame(data) if isinstance(data, dict) else data
error = agent.get_response().get("sql_database_error") if agent.get_response() else None
If the user only needs schema understanding, avoid LLM calls and use get_database_metadata as shown in workflows.
References and bundled checks
- API reference: signatures, imports, response fields, and public/private boundary notes.
- Workflows: metadata-only inspection, direct agent use, factory graph use, large-schema handling, and app-derived cues.
- SQL safety and metadata: what
_validate_sqldoes and does not guarantee, and how metadata is sampled. - Troubleshooting: symptom/cause/recovery table for imports, validation, token pressure, connection errors, and app/provider issues.
- Smoke script: local in-memory SQLite metadata and read-only safety check with no LLM call or external service.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).