retrieve-sql

Solid

Retrieve data from SQL databases — query construction, EXPLAIN verification, and safe execution. Use when the user needs data from relational databases or asks database-backed analytical questions.

AI & Automation 0 stars 0 forks Updated today MIT

Install

View on GitHub

Quality Score: 78/100

Stars 20%
0
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Retrieve-SQL (SQL 数据检索) Query SQL databases safely. ## When to Use - "How many orders were placed in Q3?" - "Query the user table for active accounts" - "Get revenue by month for 2025" - "What's the average order value by region?" ## When Not to Use - Schema migrations (`ALTER TABLE`, `CREATE TABLE`) → use database-design - Cross-database migration → not supported; recommend dedicated migration tool - Data visualization → route to dashboard-builder after retrieving data - Writing data (`INSERT`, `UPDATE`, `DELETE`) without explicit user permission ## Procedure 0. **Schema check** — if the user didn't provide the schema, read from `INFORMATION_SCHEMA` or available config. If inaccessible, ask the user for table/column names. 1. **Query construction** — build the SQL query from the user's analytical question. Use parameterized placeholders (e.g., `%s` for psycopg2, `?` for sqlite3) for any user-supplied values. 2. **EXPLAIN verification** — prefix the query with `EXPLAIN` (or `EXPLAIN ANALYZE` for PostgreSQL). Verify the query plan uses indexes for large tables and avoids full-table scans on high-cardinality columns. 3. **Safe execution** — execute the parameterized query with a read-only connection (or transaction with rollback if read-only is unavailable). 4. **Return results** — present the results as a table or structured summary. Include row count and any warnings about data freshness. ## Pitfalls - **Hardcoded connection strings**: Never write credentials or co...

Details

Author
AVA-2568
Repository
AVA-2568/MY_SKILL
Created
2 days ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category