[Read on Dashport](https://dashport.ai/documentation/connect-a-database)

Connecting DataConnect a database

Copy page

[

Dashport Docsv2.0](/documentation)

Getting Started

IntroductionCreating your account5-minute quick start

Connecting Data

Supported integrationsConnect a databaseColumn comments & AI contextSuperSheets as a sourceCredential securityRefresh intervals

Using SuperSheets

What is SuperSheets?Creating a sheetData entry & column typesFormulas & calculationsFormatting & selectionSort, filter & columnsRow operationsValidation & frozen panesImport & exportSharing & activity logKeyboard shortcutsUse as a data source

Asking Chat

How Chat worksWriting effective promptsExample conversationsBuilding charts via ChatLimits & best practices

Building Dashboards

Three ways to buildDrag-and-drop builderAsk Chat to buildSharing & permissions

Connecting DataConnect a database

Copy page

## Connect a Database[](#cd-database)

The steps below apply to PostgreSQL and MySQL. BigQuery and Snowflake have additional OAuth steps described in their individual guides.

1

Open the connection wizard

Go to `Settings → Connections → New Connection` and pick your database type.

2

Enter connection details

Fill in the following fields:

Hostyour-db.example.com

Port5432 (PostgreSQL) / 3306 (MySQL)

Databaseyour\_database\_name

Usernamedashport\_readonly

Password••••••••

3

Allowlist Dashport IPs

Add the following IPs to your database firewall or VPC security group: `52.14.210.5`, `18.221.4.33`, `3.143.171.87`.

4

Test and save

Click "Test Connection". Dashport will verify credentials and run a lightweight schema discovery query. Save on success.

Warning

We strongly recommend creating a **read-only** database user for Dashport. Dashport never writes to your database — it only reads.

### Select a Table or Write Custom SQL[](#cd-database-query-mode)

Once your database is connected, Dashport gives you two ways to define the data for each widget:

Select a Table

Browse and choose any table or view in your database. Dashport handles aggregations, filters, and grouping through the widget editor's point-and-click UI. Great for quick exploration.

Write a Custom SQL Query

Write your own `SELECT` statement and Dashport treats the result as the data source. Your query _is_ the report — all joins, aggregations, and filters are already baked in.

BI Power User Workflow

In business intelligence, a custom SQL query **is** your report. If you already know the exact data you need, write the query, connect it, and go **straight to Superdashboard** — no need to use Dashport Chat at all. This is the fastest path from database to chart.

Custom SQL

Superdashboard

— skip Chat, your data is already report-ready

### Example Custom SQL Query[](#cd-database-sql-example)

custom-query-example.sqlsql

Copy

```
-- Monthly revenue by product category — report-ready, no further transformation needed
SELECT
  DATE_TRUNC('month', o.order_date)  AS month,
  p.category                          AS category,
  SUM(oi.quantity * oi.unit_price)    AS revenue,
  COUNT(DISTINCT o.id)                AS order_count,
  ROUND(AVG(oi.unit_price), 2)        AS avg_order_value
FROM orders o
JOIN order_items oi ON oi.order_id = o.id
JOIN products    p  ON p.id = oi.product_id
WHERE o.order_date >= NOW() - INTERVAL '12 months'
  AND o.status = 'completed'
GROUP BY 1, 2
ORDER BY 1 DESC, 3 DESC;
```

Tip

Once you paste this query into the connection wizard, Dashport runs it, previews the result columns, and lets you name the connection. You can then open Superdashboard, pick this connection as your data source, and start building charts immediately — no Chat required.

### Creating a read-only user (PostgreSQL)[](#cd-database-readonly)

postgres-readonly-user.sqlsql

Copy

```
-- Create a dedicated read-only role
CREATE ROLE dashport_readonly WITH LOGIN PASSWORD 'replace_with_strong_password';

-- Grant connection access to your database
GRANT CONNECT ON DATABASE your_database TO dashport_readonly;

-- Grant usage on the target schema
GRANT USAGE ON SCHEMA public TO dashport_readonly;

-- Grant SELECT on all existing tables
GRANT SELECT ON ALL TABLES IN SCHEMA public TO dashport_readonly;

-- Grant SELECT on future tables automatically
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT ON TABLES TO dashport_readonly;
```

Previous

Supported integrations

Next

Column comments & AI context
