Natural-Language SQL with a Local LLM: Connect dbclaw to Ollama

Cloud AI tools want your schema, sometimes your data, and always your API budget. With a local model through Ollama, you can turn plain English into SQL with nothing leaving your computer — no API key, no per-token bill, and it works on a plane. Here's the full setup.

If you work with databases that hold customer data, health records, or anything under NDA, sending even your schema to a third-party API can be a non-starter. dbclaw is a local-first desktop app that turns questions into read-only SQL — and it can run that translation on a model hosted entirely on your own machine via Ollama.

Why run the model locally?

What you'll need

Step 1 — Install Ollama and pull a model

Install Ollama from ollama.com, then pull a model from your terminal:

ollama pull llama3.1:8b

Make sure the Ollama server is running (it usually starts automatically; otherwise run ollama serve).

Which local models work?

dbclaw drives the model with tools — it asks the model to call functions to inspect the schema and propose SQL. That means you need a tool-capable model. These work well:

ModelGood for
llama3.1:8bSolid all-rounder, modest hardware.
qwen2.5-coder:7bStrong at SQL specifically.
mistral-nemoGood balance of speed and quality.
command-rLarger, higher quality if you have the RAM.
💡 A model without tool support will connect but fail to produce queries. Stick to tool-capable models like the ones above.

Step 2 — Install dbclaw

Download the *-setup.exe from the releases page and run it. (It's unsigned for now, so on the SmartScreen prompt click More info → Run anyway.) Then connect a database from the top-left connection switcher — see the Postgres walkthrough if you want the details.

Step 3 — Point dbclaw at Ollama

  1. Open Settings → LLM provider.
  2. Set Active provider to Ollama (local).
  3. Set the Model to what you pulled, e.g. llama3.1:8b.
  4. Leave the base URL as http://localhost:11434 (the default).

That's it — no API key field to fill, because there's no API.

Step 4 — Ask a question, fully offline

Open the Chat tab, pick your database, and ask:

What were our top 5 selling products last month by units sold?

The local model reads your schema, writes read-only SQL, dbclaw runs it against your database, and you get a table back — all on your machine. You can disconnect from the internet and it still works.

Performance tips for local models

Small local models are impressive but not magic. A few habits keep them snappy:

What actually leaves your machine? Nothing.

With a cloud provider, dbclaw sends your question and schema (never your rows) to that provider. With Ollama, even that stays local — the model runs as a process on your own computer. Combined with dbclaw's other guarantees:

FAQ

Do I need a GPU?

No. Smaller models run on CPU; a GPU just makes them faster. Match the model size to your RAM.

Can I switch between local and cloud?

Yes. The active provider is a setting — use Ollama for sensitive databases and a cloud model when you want extra horsepower.

My local model connects but won't produce a query.

It's almost always a non-tool-capable model. Switch to llama3.1:8b, qwen2.5-coder:7b, mistral-nemo, or command-r, and make sure ollama serve is running.

Run AI SQL with zero data leaving your machine

Free, local-first, read-only. Pair it with Ollama and stay fully offline.

Download dbclaw for Windows

Keep reading

How to query PostgreSQL in plain English → Query across Postgres, MySQL, SQL Server & MongoDB at once → Full documentation →