PostgreSQL
Connect your PostgreSQL database to Terno AI and ask questions about it in plain English.
Connect a PostgreSQL database, including hosted Postgres on AWS RDS, Google Cloud SQL, Azure, Supabase, or Neon, and ask questions about live data.
Before you start
Section titled “Before you start”You’ll need:
- The host and port of your PostgreSQL server, reachable from the internet.
- A database name.
- A username and password, ideally for a read-only user.
- Admin rights in your Terno workspace, to see the option to add a datasource.
Connect PostgreSQL
Section titled “Connect PostgreSQL”- Click Add Data Connectors, open the Datasources tab, and choose Postgres.
- Choose Standard Setup or Connection URI at the top of the form.
- Leave Start exploring my database ticked (it’s on by default). Right after connecting, Terno opens a background chat that explores the database and learns its tables, joins, and metrics. You’ll find it in your chat history and can open it any time.
- Enter a Display Name and an optional Description, then fill in the fields below.
- Click Add Connection. Terno tests the connection before saving it. If the test fails, you’ll see what went wrong, and nothing is saved.
Connection fields
Section titled “Connection fields”Display Name required
Section titled “Display Name required”A name for this connection, such as Production DB or Sales warehouse. It can be up to 40 characters and must be unique.
Description optional
Section titled “Description optional”A short note on what the data is about, such as Orders, customers, and payments for our online store. Up to 1024 characters. Terno uses it to understand when to use this source.
Standard Setup
Section titled “Standard Setup”
user required
Section titled “user required”The database username Terno logs in as.
password required
Section titled “password required”The password for that user.
host required
Section titled “host required”The server address, as a domain (db.mycompany.com) or an IP address. For cloud databases, copy it from your provider’s console (for example AWS RDS, Google Cloud SQL, Azure, Supabase, or Neon).
port required
Section titled “port required”The port PostgreSQL listens on. Usually 5432.
database required
Section titled “database required”The database to analyse, such as analytics.
Connection URI
Section titled “Connection URI”
Paste a full connection string instead of the separate fields:
postgresql://username:password@host:port/databaseCreate a read-only user
Section titled “Create a read-only user”Run this as a database admin, replacing the names and password:
CREATE USER terno_readonly WITH PASSWORD 'a-strong-password';GRANT CONNECT ON DATABASE analytics TO terno_readonly;GRANT USAGE ON SCHEMA public TO terno_readonly;GRANT SELECT ON ALL TABLES IN SCHEMA public TO terno_readonly;ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO terno_readonly;After you connect
Section titled “After you connect”Terno reads your tables, columns, primary keys, foreign keys, and row counts. You’ll get a DataSource Ready notification when it’s done, and the new source appears in the sidebar’s Data Connectors panel. Expand it to see its tables.
Ask questions
Section titled “Ask questions”Start a chat and ask in plain English, for example:
- “Which 10 customers spent the most this year?”
- “What’s the average order value by month?”
- “Show a chart of new sign-ups per week this quarter.”
Terno writes the SQL for PostgreSQL, runs it, and replies with tables, charts, and an explanation. You don’t need to know SQL.
Security
Section titled “Security”- Credentials are encrypted at rest and used only to connect to your database.
- The AI never sees your password or connection string.
- SQLShield allows only a single read-only
SELECTper query. Inserts, updates, deletes, and schema changes are blocked. - Admins can hide tables, columns, and rows from groups of users. See Access control.
Troubleshooting
Section titled “Troubleshooting”Connection timed out, or Terno can’t reach the server
- Check the host and port.
- Make sure the database accepts connections from outside your network, and that no firewall or security group blocks it.
- Use a real hostname or IP address.
localhostand127.0.0.1point to Terno’s own servers, not yours. - Check the database is running.
Authentication failed
- Check the username and password. Watch for extra spaces when pasting.
- Make sure the user is allowed to log in to this database.
- If you used a Connection URI, special characters in the password (like
@,/,:) must be URL-encoded.
The database does not exist
Check the spelling of the database name. It’s the database inside the server, not the server name.
Terno can’t find my tables
- Make sure the user has
SELECTpermission on the tables. - Check you connected to the right database (not just the server) and that your tables are in a schema the user can use.
- An admin may have hidden some tables. See Access control.
See Connection errors for the full list of messages.
Best practices
Section titled “Best practices”- Use a read-only user created just for Terno, with access to only the data you want to analyse.
- Try a staging or replica database first before connecting production.
- Add a description and table descriptions so Terno picks the right tables. See Add context.
- Watch database load when asking for large, unfiltered results on production systems.
- Work with your database administrator on network access and permissions.