Which AI Can Write and Run SQL on Your Data?

★
By Mahesh ● OpenCraft AI ● Practical Guide ● tool comparison ● 13 min read ● 4 December 2026

Several AI tools can write SQL, run it against your data, and explain the output in plain English. They fall into two main groups: native cloud warehouse assistants (such as Gemini in BigQuery, Snowflake Cortex, and Databricks Assistant) that query live tables directly, and sandboxed AI agents (such as ChatGPT data analysis, Julius, or OpenCraft AI) that execute code against exported files or local folders. Picking the right one depends on whether your data sits in a managed cloud warehouse or in exported files on your desk.

Most teams hit a wall when they test a standard chatbot on a real business question. A chatbot without code execution can draft a plausible SQL query. It cannot run the code, check whether a column name exists, or catch a join that quietly duplicates rows. To get numbers you can put in a slide deck, the AI needs an execution environment that runs the query and reads the real output before summarizing it.

Two ways AI tools run queries against your data

Before comparing specific products, separate how these tools touch your data. The architecture determines what you can ask and what your security team will approve.

Live database and warehouse assistants

Cloud data platforms embed AI assistants directly inside their query editors and notebooks. Because the assistant lives next to your tables, it reads your schema metadata, writes SQL for that dialect, and runs the query under your existing permissions.

This setup fits when your company already centralizes reporting in one cloud warehouse. You avoid exporting files, and your data stays inside the warehouse boundary. The trade-off is setup: your tables need clean modeling first, and non-technical teammates still have to log into a data platform.

Sandboxed file and code agents

The second group works inside a chat interface backed by an isolated code sandbox. You attach a CSV export, a spreadsheet, or a database file, ask your question in plain English, and the agent writes and runs code against that file. Once the code finishes, the agent reads the computed output and explains it.

Setup is fast. An analyst or operations lead can export a table from a CRM, drop the file into a chat, and start asking follow-up questions right away. The trade-off is freshness, since you are querying a snapshot rather than a live production table unless you pair the agent with a local connector.

Dedicated text-to-SQL and BI chat tools

Dedicated text-to-SQL platforms and BI chat tools sit in the middle. They connect to a live database using credentials you configure, map your tables into a semantic layer, and let business users type questions in plain English. These tools work well when a whole department needs self-serve answers on recurring metrics, though they require real upfront configuration.

How to evaluate an AI SQL tool before connecting real data

Marketing pages for data tools sound identical. When you test a tool on your own work, five practical checks separate useful assistants from toys.

First, verify that the tool computes answers instead of estimating them. Ask a question that requires grouping and counting rows across a messy file. If the tool shows you the exact code it executed and the raw output table, you can audit the math. Walk away if it gives you a smooth narrative with no visible calculation.

Second, test how it handles your business definitions. “Active customer” might mean someone who logged in recently or someone on an annual contract. Look for a tool that lets you save those rules in persistent instructions or a semantic layer so you stop pasting the same caveats into every prompt.

Third, check where your data and credentials live during execution. Some tools send uploaded files to a cloud sandbox with no internet access. Others run locally on your machine so credentials stay on your laptop. Match the execution model to your company’s data policies.

Fourth, see how it recovers from a mistake. Even strong models misread ambiguous column names on the first try. Tell the agent, “That number looks too high because you included cancelled orders, please exclude them and rerun,” and watch whether it adjusts the code and recomputes cleanly in the same thread.

Fifth, check how it handles large files or multi-file questions. Real reporting rarely lives in one clean table. You often need to join an orders export with a product catalog or compare two quarterly files side by side to spot what changed. Test whether the tool keeps multiple files in one workspace and remembers your previous steps.

A worked example with a returns question

To see what a reliable AI query workflow looks like in practice, walk through a common operations question. Suppose you manage an online store and want to know which product categories had the highest return rate last quarter, excluding cancelled orders and internal test accounts.

Step 1: State the question and the edge cases clearly

Give the AI the business rules upfront rather than hoping it guesses them from column names. A clear prompt looks like this:

Using the attached orders and returns tables, calculate the return rate by product category for last quarter. Exclude any order where status is cancelled, and exclude any customer email ending in our company domain. Show the SQL you ran, the summary table, and a short plain-English explanation of what stands out.

Step 2: Inspect the generated query before trusting the summary

A capable AI tool inspects the column headers first, then writes a query that handles the filtering and division safely. For a SQL-based run, look for something readable and explicit:

SELECT
  o.product_category,
  COUNT(DISTINCT o.order_id) AS completed_orders,
  COUNT(DISTINCT r.order_id) AS returned_orders,
  CAST(COUNT(DISTINCT r.order_id) AS FLOAT) / NULLIF(COUNT(DISTINCT o.order_id), 0) AS return_rate
FROM orders o
LEFT JOIN returns r
  ON o.order_id = r.order_id
WHERE o.order_date >= '2026-07-01'
  AND o.order_date < '2026-10-01'
  AND o.status <> 'cancelled'
  AND o.customer_email NOT LIKE '%@ourcompany.com'
GROUP BY o.product_category
ORDER BY return_rate DESC;

These lines are readable without daily SQL experience. You can confirm the date range, see that cancelled orders are excluded, and check that NULLIF protects against dividing by zero.

Step 3: Run the query and sanity-check the row counts

Once the tool executes the query, look at the raw counts before reading the prose summary. If completed_orders looks suspiciously small or huge, the join might be dropping rows or duplicating them. Ask a follow-up right away: “Check if any order_id appears twice in the returns table.” The AI runs a quick check and confirms whether partial returns skewed the count.

Step 4: Ask for the plain-English explanation and the next slice

After the numbers check out, the plain-English explanation becomes useful. The AI can point out which category sits at the top, note whether a small order volume makes the rate noisy, and suggest the next breakdown. Because the results stay in the conversation, you can follow up with, “Now break down the top category by shipping carrier and plot a bar chart,” without starting over.

Comparing the main AI options for running SQL and explaining results

Different tools solve different parts of this workflow. Capabilities shift quickly across vendors, so check their current version and plan details before committing to a team rollout.

Tool or category Where code runs Live database connection Best fit
Cloud warehouse assistants (Gemini in BigQuery, Snowflake Cortex, Databricks Assistant) Inside your cloud data warehouse Yes, native to that platform Data teams already centralized on one cloud warehouse
ChatGPT data analysis Isolated cloud sandbox File uploads by default; check their current version for connectors Quick one-off analysis on exported CSVs and spreadsheets
Claude Cloud code tool or local MCP tools, depending on plan; check their current version Depends on setup and MCP tools; check their current version Writing, explaining, and refining SQL with strong reasoning
Dedicated data tools (Julius and text-to-SQL BI tools) Managed cloud environment Often supported via database credentials; check their current version Teams wanting a dedicated analytics chat or self-serve BI layer
OpenCraft AI (Ocai) Cloud sandbox or local desktop sandbox Not documented for direct live databases; works on attached exports and local folders Computed sandbox analysis on files and local folders

Cloud warehouse assistants

Gemini in BigQuery, Snowflake Cortex, and Databricks Assistant are built for teams whose data already lives in those platforms. They understand the platform’s SQL dialect and respect existing role-based access inside the workspace. Analysts stay in their normal editor. Check their current version for natural-language chat features aimed at non-technical users, as these platforms keep expanding beyond the SQL editor.

General chat tools with code execution

ChatGPT data analysis popularized uploading a CSV or Excel file and letting an AI run Python in a sandbox to clean messy rows and draw charts. Claude is widely used for drafting complex SQL and debugging tricky joins, and it supports tool connections depending on the client you use (check their current version for built-in execution and connector limits). Both are strong generalists. Teams still run into friction when they try to standardize metric definitions across sessions or keep local credentials strictly on a company laptop.

Dedicated data analysis and text-to-SQL tools

Tools like Julius focus specifically on conversational data analysis, taking uploaded files or connected sources and returning tables, charts, and plain-English summaries. Dedicated text-to-SQL tools go further by connecting directly to production or reporting databases and maintaining a semantic layer for business terms. Check their current version for supported database engines and security controls before connecting sensitive tables.

Where OpenCraft AI fits (and where it does not)

OpenCraft AI approaches data work through its agent, Ocai, which runs on open models (Ocai Swift, Ocai Core, Ocai Ultra, GLM, DeepSeek, and MiMo) that you pick in the model selector. If one model stalls during a task, another takes over. Some models support context windows up to 1.3M tokens, and when your material is larger than the window, Ocai works over it in pieces.

For querying and summarizing data, Ocai relies on code execution. When a question requires real calculation, Ocai writes and runs Python inside an isolated sandbox on OpenCraft AI’s servers and brings the computed result back into the chat. You do not need to know Python. You can attach an export (a CSV, a spreadsheet, or a database file) using attachments, ask for the result in plain language, and let Ocai clean and summarize the rows. That cloud sandbox has no internet access and works only with what you give it. If a result looks wrong, you tell Ocai what you expected and it reruns the code. Because the output stays in the conversation, you can ask for a chart, a different grouping, or the same analysis on a second file. You can read more about how this isolation works in the guide on running AI agent code in a safe sandbox or see how it handles structured outputs like a finished spreadsheet or financial model.

Two workspace features help when you run recurring data checks. Projects keep your chats, files, whole folders, instructions, and skills together for one body of work, which pairs well with keeping context across sessions. Skills, global or per project, let you save reusable instructions, such as your company’s exact metric definitions or preferred report format, so Ocai applies them consistently every time you drop in a new export.

If your workflow needs local files or private network access, installing the desktop app moves the desktop sandbox onto your laptop. Its blast radius stays limited to one folder you choose. It also gains per-server, per-domain internet access and can host MCP integrations attached per chat, with credentials remaining on your machine. Because requests originate from your laptop, they can reach private endpoints such as an internal tool behind an office VPN, while the AI model itself still runs in the cloud.

Pricing is pay as you go, with no rate limits, free credits to start without a card, and credits that never expire; you can check current details on the OpenCraft AI pricing page or review team options on the OpenCraft AI enterprise page.

Just as important is where OpenCraft AI does not fit. A direct, built-in live database connection is not something the OpenCraft AI site documents. If your primary requirement is pointing an AI straight at a live cloud warehouse without exporting files or setting up local tooling, a native warehouse assistant or a dedicated text-to-SQL platform will fit that specific job better. OpenCraft AI fits best when you work with exported datasets, spreadsheets, local folders, or multi-step analysis where you want computed answers, reusable metric definitions, and a sandbox that “can’t escape” and “can’t delete your files”.

Frequently asked questions

Can an AI write and run SQL without me knowing how to code?

Yes. Both cloud warehouse assistants and sandboxed code agents let you ask questions in plain English and receive plain-English summaries. You still need to check the logic. Asking the AI to explain its filters and joins in plain language lets you spot missing exclusions or wrong date ranges even if you have never written SQL yourself.

Is it safe to let an AI run queries on company data?

Safety depends on where the code runs and what permissions it holds. A cloud sandbox with no internet access limits exposure to the specific files you attach, while a local desktop sandbox restricts file access to a single chosen folder and keeps credentials on your machine. For live databases, always verify how the vendor handles permissions and whether queries execute inside your own cloud environment.

Why do AI tools sometimes return wrong numbers even when the SQL runs?

A query can run without syntax errors and still answer the wrong business question. Common causes include joining tables at different levels of detail (which inflates totals), forgetting to filter out test accounts or cancelled orders, or misunderstanding a vague column name. Saving your metric definitions in reusable instructions and checking raw row counts before trusting percentages prevents most of these errors.

Does OpenCraft AI connect directly to a live SQL database?

No direct live-database connector is documented on the OpenCraft AI site. Instead, you can attach an export (such as a CSV, spreadsheet, or database file) and ask Ocai to query and summarize it with code in the sandbox. Desktop app users have another option: the local sandbox works with a chosen folder and can host MCP integrations whose requests originate directly from your machine.

Should I use a warehouse assistant or a sandboxed AI agent for data analysis?

Choose a warehouse assistant if your data is already modeled cleanly in one cloud platform and you need live queries on production tables. Choose a sandboxed AI agent if your data arrives as exports, spreadsheets, or local files, or if you want to combine data analysis with document review and reusable reporting workflows in one workspace.

Scroll to Top