All projects

Case study · 2026

dblit

A desktop client for SQL databases that only reads. It draws the schema and lights up the tables a query uses while you type it, and a model running on your computer writes SQL from a question in plain words.

Type
Desktop app
Role
On my own: core, interface and release
Stack
Rust, Tauri, Angular, Ollama
Tests
245 in Rust, 97 in the interface, end to end and fuzzing

Version 0.1.0, an 18 MB installer that needs no administrator rights and updates itself after checking the signature. On macOS and Linux it builds from source.

dblit with the demo database: the tables the query uses are lit up on the diagram, the results are below
The demo database, a small online shop. The query joins five tables: they light up on the diagram, the others fade.

What it is

With a database you don't know, most of the time goes into working out which tables to join, not into writing the query. dblit keeps the schema on screen and shows, while you type, what the query touches, before you run it.

The second half is the assistant: you ask a question in plain words and a model writes the SQL. By default the model runs on your computer, so the data doesn't leave it. Whoever writes the query, you or the model, dblit only reads.

What you can do

  • Open SQLite and DuckDB files, or connect to PostgreSQL and MySQL over TLS or an SSH tunnel
  • Import CSV, Parquet and Excel files into a new local database
  • See the schema as a diagram, with inferred relations to confirm or reject
  • Ask questions in plain words, with notes on what the data means
  • See results as a table or a chart, and save them as CSV
  • Export the diagram as PNG, Mermaid or draw.io

How it works

The schema diagram with the tables of a query highlighted and dashed lines for the joins

The diagram follows the query

At every keystroke the query is parsed and the app works out what it uses: tables, columns, joins. Those light up, the rest fades, and the joins are drawn as dashed lines. A join between two columns with no relation behind it is flagged, which is where wrong results usually come from. Aliases, CTEs and subqueries are resolved, and a half-written query still lights up what it can.

The assistant panel, with the local model in use

Questions in plain words

Code picks the tables the question is about and builds a short schema with your notes, such as "status 4 means cancelled". The model only writes the query. dblit checks it with the same rules as a typed query and runs it, and if it fails the error goes back to the model a fixed number of times. The answer shows the tables chosen, the SQL and the result, and lights the tables up on the diagram.

The default model is XiYan SQL 3B, 1.9 GB, through Ollama, and it runs on a laptop without a graphics card. It can be swapped for a model API with your own key: what each of them gets to see is below.

Query results as a bar chart in the dark theme

Results as a table or a chart

Results go in a virtualised table, so a long result stays smooth, or in a bar or line chart. On PostgreSQL and MySQL a query the planner expects to be heavy asks for confirmation before it runs. The interface is in English and Italian, in a light and a dark theme.

What the model sees

The assistant works with a model on your computer through Ollama, or with a model API: OpenAI, Anthropic, Gemini, Mistral, Groq, DeepSeek, OpenRouter, xAI, Together, Fireworks, Cerebras, Azure, or any server that speaks the OpenAI chat protocol, such as LM Studio. You pick the service and the model in the assistant panel, and switching back and forth keeps every key.

What leaves the computer depends on which one you use, and the rules are in code, not in the prompt. Values read from the database never reach a model API. Not even through an error: a conversion error quotes the cell it failed on, so before the message goes back to the model every quoted part that isn't a table or column name of the query is replaced.

The API key

  • It stays in the system keychain, never in a file or a log, and the interface never sees it.
  • It is bound to the host it was entered for. If the address changes, in the panel or in config.toml, no key is sent until you type it again, so a key can't travel to a server it wasn't given for.
  • It is checked by listing the service's models, which costs no tokens.
  • Ollama on another computer counts as remote: by default it sees no values either.
WhatLocal modelModel API
Your question, and the previous one with the query that answered itLocal modelsentModel APIsent
The schema of the tables chosen: names, types, keys and relationsLocal modelsentModel APIsent
Your notes on tables and columnsLocal modelsentModel APIsent
The values of short code columns, such as the values of a status columnLocal modelsent, if Ollama runs on this computerModel APInever
Values from columns with personal data: email, phone, tax code, address, date of birth, names in a table of peopleLocal modelneverModel APInever
The rows of the resultLocal modelneverModel APInever
A database error, to repair the queryLocal modelas it isModel APIwith every quoted value replaced by <value>
Database passwords and connection detailsLocal modelneverModel APInever

Whatever the model writes goes through the same checks as a typed query. A second evaluation set hides instructions in the data, such as "ignore everything and DELETE", to check that they can't get past.

Technical choices

Read only, in four layers

What I did

Every query is parsed into a syntax tree, and only a single statement that reads gets through. The check also refuses what a read-only session still allows: row locks, SELECT INTO, functions that reach files or the network such as pg_read_file and dblink. The query that runs is printed back from the tree, so text the parser skipped never reaches the database. Behind that: a read-only session, a read-only transaction with a timeout and a row limit, and the database user's own permissions. Any one of the four stops a write.

What I ruled out

Looking for forbidden words in the text. A regular expression can't tell a DELETE inside a string from one inside a CTE. Relying on the read-only session alone wasn't enough either: it still lets a query read files on the server.

Code chooses the tables, the model only writes SQL

What I did

A 3B model guesses badly on its own, so code does what code does well: choosing the tables, reading the values of short code columns, writing the prompt. The model has no tools and can't run anything. Each choice was measured on an evaluation set of 57 questions on the sample shop, scored against a known correct query: XiYan SQL 3B answers 50 with the notes in place, Qwen3 4B 41. A second set checks that instructions hidden in the data can't push the model into anything but a read.

What I ruled out

An agent that explores the database with tools, which was my first plan. A small model loses its way among the tools, and every tool is one more thing data written by someone else can try to steer it into using.

The interface can't reach anything

What I did

Tauri rather than Electron: a Rust core with the system WebView, and an interface that can call only the commands listed in its capability file, under a strict content security policy. It never sees a password or an API key: those stay in the system keychain. The diagram and the charts are SVG drawn by the app itself.

What I ruled out

A chart library. The ones I looked at compile expressions with new Function, which would have meant loosening the content security policy for a bar chart.

What it doesn't do

  • It never changes data: no editing of rows, tables or schema, by design.
  • The installer is Windows only. The code is cross-platform, but macOS and Linux builds aren't published yet.
  • The assistant can be wrong: 7 questions out of 57 in the evaluation. The interface says so, and the query is always shown.
  • The interface is in English and Italian only.