Text-to-SQL BI Assistant: PostgreSQL, MySQL, SQLite, CSV

    by Medhedi Chebil

    0

    Your agent reads your database schema, writes one SQL query in the right dialect, runs it read-only, and answers with the key figures, the result table and the SQL it used.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    What it does

    • Answers business questions (revenue, margins, rankings, trends) by writing and running SQL on your data
    • Reads your schema first: tables, join paths, real category values and number ranges
    • Blocks every write: only one SELECT runs, on a read-only connection, with time and row limits
    • Connects to PostgreSQL and MySQL/MariaDB servers, SQLite files or CSV exports
    • Learns your metrics: saves the answers you confirm and reuses them for similar questions

    Who it's for

    Business and data analysts

    Ad-hoc questions answered with the SQL shown, so every figure can be checked and reused.

    Try asking: “Which products had the highest profit margins last month?”

    Small business owners

    Figures from your sales exports without writing SQL or waiting for a dashboard.

    Try asking: “Which month of 2025 had the highest revenue, and how does it compare with the same month in 2024?”

    Developers and BI students

    A safe way to explore a PostgreSQL, MySQL or SQLite database or star schema from their agent.

    Try asking: “Quel est le chiffre d'affaires par catégorie pour 2024 ?”

    Text-to-SQL BI Assistant: PostgreSQL, MySQL, SQLite, CSV

    Example session with this skill installed

    Build the text-to-sql-bi demo database and tell me which store had the best margin rate in 2025.

    • Read your context and instructions
    • Compiled the text-to-sql bi assistant

    Summary

    Monastir Marina had the best margin rate in 2025:

    26.8% (190,577 TND of margin on 711,011 TND of revenue). The spread between stores is small, from 26.3% to 26.8%, so no store is a clear outlier. Lac 2 brings in the most revenue (781,645 TND) and the most margin in value.

    Margin rate by store, 2025

    store_namecityrevenue_tndmargin_tndmargin_rate_pct
    Monastir MarinaMonastir711010.83190576.6226.8
    Ariana SoukraAriana715415.06190101.4826.6
    Lac 2Tunis781645.39207458.7126.5
    Sfax VilleSfax711982.44188576.8526.5
    Sousse CornicheSousse735723.92195186.8026.5
    GabesGabes706668.90185827.7726.3
    Tunis CentreTunis676557.98178099.9426.3

    The query (run read-only)

    SELECT s.store_name, s.city,
           ROUND(SUM(f.revenue), 2) AS revenue_tnd,
           ROUND(SUM(f.revenue) - SUM(f.cost), 2) AS margin_tnd,
           ROUND((SUM(f.revenue) - SUM(f.cost)) / SUM(f.revenue) * 100, 1) AS margin_rate_pct
    FROM fact_sales f
    JOIN dim_store s ON s.store_key = f.store_key
    JOIN dim_date d ON d.date_key = f.date_key
    WHERE d.year = 2025
    GROUP BY s.store_name, s.city
    ORDER BY margin_rate_pct DESC
    

    Assumption: margin rate = (revenue − cost) / revenue, with revenue after discounts.

    Next steps

    • Ask "Break down Monastir Marina's margin by product category" to see what drives it.
    • Confirm this answer is right and I will save it to the example bank, so similar questions are answered faster next time.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Ask your data questions, get checked answers

    "Which store had the best margin in 2025?" "Top 5 B2B customers?" "Quel est le CA par catégorie ?" Ask in plain English or French. Your agent reads your database schema, writes one SQL query in the right dialect, runs it read-only, and answers with the key figures, the result table and the SQL it used.

    Works on your data

    • PostgreSQL and MySQL / MariaDB servers
    • SQLite files (.sqlite, .db)
    • CSV exports: one command turns a folder of CSV files into a database (delimiter and column types detected, codes like 007 kept as text)

    Your server password never appears in commands or answers: the connection URL is read from an environment variable and masked in error messages.

    Cannot change your data

    • Only one SELECT (or WITH … SELECT) statement is accepted
    • PostgreSQL and MySQL: every query runs in a READ ONLY transaction that is always rolled back; system schemas and risky server functions (pg_read_file, INTO OUTFILE, LOAD_FILE, SLEEP, locks…) are refused
    • SQLite: the file is opened read-only and an authorizer blocks writes, PRAGMA, ATTACH and system tables
    • Queries stop after 10 seconds and results are capped at 200 rows
    • You can hide tables, for example a table with personal data

    If the guard refuses a query, the agent stops and tells you: it never tries to work around it. For the strongest protection on a server, connect with a database user that has SELECT rights only.

    Gets better with use

    Answers you confirm are saved in a small example bank for that database. The closest examples are retrieved for each new question, so your own metric definitions are reused. It works offline, in English and French.

    Easy to try

    A demo retail warehouse (60,000 sales lines, 2024–2025, 32 solved questions) lets you try it in one minute, with no database to set up.

    Limits

    SQL Server, Oracle and other databases are not connected directly: export the tables to CSV first.

    Works with PostgreSQL, MySQL/MariaDB, SQLite and CSV. SQL Server, Oracle and other databases are not connected directly: export the tables to CSV first. One query per question, read-only, stopped after 10 seconds and capped at 200 rows (both adjustable). Example search matches shared words, not meaning, so it helps most when questions are phrased like earlier ones.

    Python 3.9+, no API key. SQLite/CSV: standard library only. PostgreSQL: pip install "psycopg[binary]". MySQL/MariaDB: pip install pymysql. Server URLs are read from an environment variable (env:DATABASE_URL) and masked in errors. Scripts: inspect_db.py (dialect, schema, join paths, real values), run_query.py (exit codes 0 OK, 1 error, 2 refused), examples.py (per-database bank of verified question-to-SQL pairs, local embedder), csv_to_sqlite.py. Guard: one SELECT/WITH; SQLite read-only file + authorizer; PostgreSQL/MySQL READ ONLY transaction always rolled back, system schemas and file/session/lock functions refused; table allowlist; timeout; row cap. Tested on PostgreSQL 16 and MariaDB 10.11.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 1 day ago

    Software
    Python 3.9+
    Optional
    PostgreSQLMySQL

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Network Access
    Environment Variables

    Terminal: runs the Python scripts. Read files: the SQLite or CSV files the user points to. Write files: the example bank (.examples.json) and an optional CSV export of results. Network: only to reach the user's own PostgreSQL or MySQL server, and only when they connect one. Environment variables: reads the connection URL from the variable the user names (for example DATABASE_URL), so the password is never typed in commands.

    Listed1 day ago

    What's inside

    Creator

    Medhedi Chebil

    Medhedi Chebil

    Frequently Asked Questions

    PostgreSQL, MySQL and MariaDB servers, SQLite files (.sqlite, .db) and CSV files. CSV files are turned into a SQLite database with one command. For SQL Server, Oracle or other databases, export the tables to CSV first.

    A short answer with the key figures, the result table, the SQL query that produced it, and any assumption the agent made (for example, whether revenue is before or after discounts). You can also save the full result as a CSV file.

    The skill only runs single SELECT queries. On PostgreSQL and MySQL each query runs in a READ ONLY transaction that is always rolled back, and risky server functions and system schemas are refused. On SQLite the file is opened read-only. If a query is refused, the agent stops instead of trying another way. For the strongest protection, connect to a server with a database user that only has SELECT rights.

    Install the driver once (pip install "psycopg[binary]" for PostgreSQL, pip install pymysql for MySQL/MariaDB), then put your connection URL in an environment variable such as DATABASE_URL in your own terminal. The agent uses env:DATABASE_URL, so your password never appears in commands, files or answers, and it is masked in error messages.

    As you would ask an analyst, in English or French: "Revenue by category in 2025", "Top 5 customers by margin", "Quel magasin a la meilleure marge ?". Name the period and the measure when you can. If a term is ambiguous, the agent asks one short question or states the assumption it made.

    Yes, from answers you confirm. When you say an answer is right, the question and its SQL are saved in a small example file for that database, kept on your computer. For each new question, the closest saved examples are reused, so your own definitions (margin, active customer, fiscal year) are applied consistently.

    New in Business & Operations

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Business & Operations.