On this page
A database can feed a dashboard. Connect it once, build a query that adds up what you care about (revenue per month, orders per status, sign-ups per country), and Threadful reads it again on a schedule. The numbers and tables on your dashboards follow along.

Threadful only reads. Nothing you build here can add, change or delete anything in your database.
How to connect a database
- Open Dashboards, press Data, and under Databases press Connect a database. (On an empty dashboard it's also under Or read from a database, and under Add. Adding a data source offers it too, under Or.)
- Choose PostgreSQL, MySQL / MariaDB or SQLite file. PostgreSQL covers services like Neon and Supabase; MySQL covers MariaDB, PlanetScale and Amazon RDS.
- Fill in the Server, Port, Database, User and Password, or paste a connection address (like postgres://user:password@host:5432/database) in the box above them and it fills the rest in. For a SQLite file, Choose the file.
- Press Check the connection, then Connect.
The password is kept encrypted by your computer's keychain and never shown again. Leave it empty when you edit a connection to keep the one saved.
Secure connection is on by default for a database on another computer. Choose Encrypted, and check the server's certificate when you want the server's identity checked too.
How to connect through SSH
Some databases only accept connections from their own server or network. For PostgreSQL and MySQL / MariaDB, Threadful can reach them through an SSH server for you; there's no tunnel to start by hand.
- In Connect a database, switch on Connect through SSH.
- Fill in the SSH server, SSH port (usually 22) and SSH user.
- Choose how to log in: Key file (press Choose the key file, and write its passphrase if it has one) or Password.
- Write the database's Server and Port as the SSH server sees them. When the database runs on the SSH server itself, that's usually localhost and the usual port.
- Press Check the connection. The first time, Threadful shows the SSH server's host key fingerprint (it starts with SHA256:) and sends nothing secret yet. Compare it with the server's own (
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pubon the server shows it, or ask whoever runs it), then press It matches: trust this server. The check runs again through the tunnel. - Press Connect.
What is kept:
- The SSH password or key passphrase goes into your computer's keychain, like the database password. Only the key file's location is kept, on this computer; the key is read from the file each time.
- The host key you confirmed. If the server later offers a different one, the connection is refused and you're told it changed, with both fingerprints. That happens when a server is rebuilt, and also when something sits between you and it. When you know the server was rebuilt, press The server was rebuilt: trust the new key. Changing the SSH server or port asks you to confirm again.
How the tunnel works: it opens on this computer on 127.0.0.1 only, so nothing else on your network can use it. Queries, scheduled data sources and the AI's database tools all go through it. If the SSH connection drops (a laptop asleep, a network change), the next read connects again by itself. A tunnel nobody used for five minutes closes, and every tunnel closes when you quit Threadful. The read only checks are the same as for a direct connection.
When something fails, the message says which step: SSH server (it couldn't be reached, or its host key is unknown or changed), SSH login (the user, key file, passphrase or password was refused) or Database behind the SSH server (the SSH server couldn't reach the database, or the database refused the user or password).
Read only, checked when you connect
Before a connection is kept, Threadful asks the server itself, and shows what it found:
- Reached the server, with its version.
- The server confirmed a read only session. Every query runs inside a read only transaction, so the server refuses any change, even if the account could make one. A server that doesn't confirm it is not used, and the connection is not saved.
- Only reading queries are sent. Each query is one SELECT. Anything that would change data, run more than one query or take a lock is refused before it is sent.
- The account itself can only read. If the account could change data, you're told which tables, and the connection is marked Read only session instead of Read only. It still can't change anything here, but a read only account is safer.
Press Show how to make an account that can only read for the few lines to give your administrator. To refuse such accounts altogether, switch on Only connect with an account that can't change data.
How to build a query
Press Query beside a connection (or Add → Query a database). The editor has the database's tables on the left. Click a table to start from it, then click its columns to add them.
Build it is the visual editor:
- Start from a table, and Add a related table to join the tables it's linked to. only matches keeps rows that have a match in both; keep all keeps every row of the first table.
- Columns: for each, choose how it's shown. Each value groups by it; Total, Average, Smallest, Largest, Count and Count different work it out per group; By day, By week, By month, By quarter and By year cut a date into periods. Give a column a name to show in the results, and press the arrow to sort by it.
- Only rows where adds filters (is, is more than, is between, contains, is in the last 30 days, is empty…). With more than one you choose All of these or Any of these.
- At most limits the rows (up to 10,000).
A sentence under the editor says what the query does in words, and The SQL it writes shows the SQL for your database, ready to copy or to edit as SQL.
SQL is for a query you write yourself: one SELECT (or WITH … SELECT). Press Ctrl Enter to run it.
Press Run to see the rows, with how long it took. Queries stop after 30 seconds.
Beside Run, a mark says how heavy the query looks before you run it: Light, Heavy or Very heavy. It comes from the database's own plan for the query, which runs nothing: reading every row of a big table, pairing every row of one table with every row of another, shuffling every row, or bringing back far more rows than are kept. A heavy one says why and how to narrow it (a date range, a filter, a limit), and that a query here only reads, so it never blocks anyone's changes to rows; a long one can hold up changes to a table's structure until it ends. Click the mark to see the reasons any time. Save as CSV beside the rows saves everything the query reads (up to 10,000 rows) as a file Excel and Google Sheets open, where you choose.
How to say what you want
Type it in the box at the top ("revenue per month for paid orders, newest first") and press Write the query. The AI reads your tables and writes the query, tries it on the database, and if the database answers with an error it sees the error and fixes the query. You get the visual editor to adjust when the question fits it, and SQL when it doesn't. The AI is held to the same rule as everything else here: it can only read.
Once there's a query, the same box changes it: say "only the last 30 days" or "by week instead" and press Change it. The AI starts from the query you have and keeps the rest.
Try next under it offers a few changes worth a look once there are rows (narrowing it, another breakdown, the top ten, another figure); click one to make it.
This needs an AI model in Settings → AI models.
Keep it and read it again
Under the editor, name the query and choose Read it again: only when you ask, every 5, 15 or 30 minutes, every hour, every 6 hours, every day or every week. Each read replaces the rows, or adds them with when they were read, to keep a history. Press Save the query.
It appears under Sources as a Database query, with its rows and when it was last read, and Read it now reads it straight away. Like every source it is read while Threadful is open.
Choose the figures to read yourself: put the totals in the query. A query that returns one row per month with the month first and the total after is the easiest to chart.
Put it on a dashboard
Press Save and put it on a dashboard. To put a saved query on another dashboard, open it from Sources, make a change or none, and press the same button. Choose:
- A chart over time: needs a number column and a date column. Each row is a dated value, added up per day, week or month.
- One number: with a date column it's added up per period; without one the figure is taken as the query returns it each time it's read, and its history is kept from then on.
- The rows as a table.
Then choose the Title and the dashboard, or A new dashboard. A number tracked this way shows under Numbers like any other and updates whenever the query is read.
What the AI can do
In the chat, the AI can list your databases and their tables, try a SELECT and look at the first rows, and add a database query as a data source. It never sees your password and it can't connect a new database; you do that here. It can only read.
If something goes wrong
- Nothing answered: the server isn't running, the port is wrong, or a firewall is in the way.
- The server refused the user name or password: check them; a password with special characters is fine when typed in the box.
- No database called…: the name is wrong for that server.
- This account can't see any tables: the user needs permission to read them.
- A query that's too slow is stopped after 30 seconds. Narrow it with a filter or a date range.
Related
- Dashboards and data: the dashboards a query feeds, and the other kinds of data source.
- Automations: react when a number changes.
Every page of the guide
The same guide is in the app: open Help or press F1. Something missing or unclear? Write to hello@threadful.ai.
