Guide

How to connect your database

Ask DB runs on our server; all you need in your network is a small connector. It opens a secure outbound connection to us by itself — so no public IP, no VPN and no open ports.

A one-minute walkthrough in Ukrainian with subtitles — an English version is on the way.

What you'll need

Step 1. Create a read-only user

Optional, but highly recommended: even if something goes wrong, such a user physically can't change anything. Run this in the database as an administrator (use your own password):

-- MySQL / MariaDB
CREATE USER 'askdb_readonly'@'%' IDENTIFIED BY 'strong-password';
GRANT SELECT ON your_database.* TO 'askdb_readonly'@'%';

-- PostgreSQL (in the target database)
CREATE ROLE askdb_readonly LOGIN PASSWORD 'strong-password';
GRANT USAGE ON SCHEMA public TO askdb_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO askdb_readonly;
You can grant access to specific tables instead of the whole database: GRANT SELECT ON your_database.orders TO … (in PostgreSQL — GRANT SELECT ON orders TO …). The AI will see only those. In MySQL, instead of '%' it's better to specify the IP of the server running the connector. In PostgreSQL the AI sees tables from the user's search_path schemas — usually public.

Step 2. Create a connection in Ask DB

  1. Sign up and confirm your email.
  2. Add a new connection, pick the database type and the “Via connector” mode.
  3. You'll see a ready docker run command with your personal token.
The token is shown only once — we store just its fingerprint. Lost it? Issue a new one in the connection settings; the old one stops working immediately.

Step 3. Start the connector

Copy the command from your account to your server. It looks like this:

docker run -d --name adb-connector --restart unless-stopped \
  -e CONNECTOR_TOKEN=adbc_… \
  -e GATEWAY_URL=wss://connect.ask-db.com.ua/v1/connect \
  -e DB_DSN='mysql://USER:PASSWORD@HOST:3306/DATABASE' \
  askdb/connector:latest

Replace USER, PASSWORD, HOST and DATABASE in DB_DSN with your own:

As soon as the connector starts, the page in your account will detect it and show which database and user it connected with.

After a server reboot

The connector comes back on its own (--restart unless-stopped) and reconnects to Ask DB with the same token — nothing to repeat. If you stopped the container by hand, start it with docker start adb-connector. Don't run docker run a second time — the name is taken. If you lost the command or the token, create a new one in the dashboard; the old one stops working.

Without Docker

The connector is a single program with no dependencies. If you don't have Docker, download it for your system from ask-db.com.ua/download/connector (checksums are in SHA256SUMS) and pass the same variables as in the docker run command:

# Linux (for ARM — linux-arm64) and macOS on Apple Silicon (darwin-arm64)
curl -fLo adb-connector https://ask-db.com.ua/download/connector/latest/adb-connector-linux-amd64
chmod +x adb-connector
CONNECTOR_TOKEN=adbc_… \
GATEWAY_URL=wss://connect.ask-db.com.ua/v1/connect \
DB_DSN='mysql://USER:PASSWORD@HOST:3306/DATABASE' \
./adb-connector

# Windows (PowerShell), file adb-connector-windows-amd64.exe
$env:CONNECTOR_TOKEN="adbc_…"
$env:GATEWAY_URL="wss://connect.ask-db.com.ua/v1/connect"
$env:DB_DSN="mysql://USER:PASSWORD@HOST:3306/DATABASE"
.\adb-connector-windows-amd64.exe
Here HOST can be localhost if the database runs on the same computer. The connector runs while the terminal window is open; to keep it running, make it a service (systemd, Windows Task Scheduler).

Step 4. Ask your first question

Open the connection's chat and ask something you already know the answer to — it's the easiest way to check the quality. If your data has quirks (“status 3 means a cancelled order”), write them down in “Connection settings → AI knowledge”.

Connector settings

Optional variables, if you need to limit the load on the database:

VariableDefaultWhat it does
MAX_ROWS1000Maximum rows in a response
QUERY_TIMEOUT_MS30000Timeout for a single query; a longer query is stopped in the database too
MAX_CONCURRENT_QUERIES4How many queries can run in the database at once
QUERY_LOG_FILE—File where the connector logs every query it runs (JSON Lines)

Useful commands

# view the log: connection, every query run
docker logs -f adb-connector

# cut off Ask DB's access to the database — instantly
docker stop adb-connector

Something's not working?