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

§2.2Connect a databaseContents▾

Dashport Docsv2.0

07/35

Search the documentation

⌕/

1.  [01Getting Started](/documentation)3
    
    1.  [Introduction](/documentation/introduction)
    2.  [Creating your account](/documentation/creating-your-account)
    3.  [5-minute quick start](/documentation/5-minute-quick-start)
2.  [02Connecting Data](/documentation/connecting-data)−
    
    1.  [Supported integrations](/documentation/supported-integrations)
    2.  [Connect a database](/documentation/connect-a-database)
    3.  [Column comments & AI context](/documentation/column-comments-ai-context)
    4.  [SuperSheets as a source](/documentation/supersheets-as-a-source)
    5.  [Credential security](/documentation/credential-security)
    6.  [Refresh intervals](/documentation/refresh-intervals)
3.  [03Using SuperSheets](/documentation/using-supersheets)12
    
    1.  [What is SuperSheets?](/documentation/what-is-supersheets)
    2.  [Creating a sheet](/documentation/creating-a-sheet)
    3.  [Data entry & column types](/documentation/data-entry-column-types)
    4.  [Formulas & calculations](/documentation/formulas-and-calculations)
    5.  [Formatting & selection](/documentation/formatting-and-selection)
    6.  [Sort, filter & columns](/documentation/sort-filter-columns)
    7.  [Row operations](/documentation/row-operations)
    8.  [Validation & frozen panes](/documentation/validation-frozen-panes)
    9.  [Import & export](/documentation/import-and-export)
    10.  [Sharing & activity log](/documentation/sharing-activity-log)
    11.  [Keyboard shortcuts](/documentation/keyboard-shortcuts)
    12.  [Use as a data source](/documentation/use-as-a-data-source)
4.  [04Asking Chat](/documentation/asking-chat)5
    
    1.  [How Chat works](/documentation/how-chat-works)
    2.  [Writing effective prompts](/documentation/writing-effective-prompts)
    3.  [Example conversations](/documentation/example-conversations)
    4.  [Building charts via Chat](/documentation/building-charts-via-chat)
    5.  [Limits & best practices](/documentation/limits-and-best-practices)
5.  [05Building Dashboards](/documentation/building-dashboards)4
    
    1.  [Three ways to build](/documentation/three-ways-to-build)
    2.  [Drag-and-drop builder](/documentation/drag-and-drop-builder)
    3.  [Ask Chat to build](/documentation/ask-chat-to-build)
    4.  [Sharing & permissions](/documentation/sharing-and-permissions)

1.  [Docs](/documentation)
2.  /[Connecting Data](/documentation/connecting-data)
3.  /Connect a database

⧉Copy page▾

§ 2.2/Connecting Data

# Connect a Database

The steps below apply to PostgreSQL and MySQL. BigQuery uses a service account; Snowflake uses a dedicated read-only role. Follow their individual setup guides.

4 stepsTick steps off as you go

2.  01
    
    Open the connection wizard
    
    Go to `Settings → Connections → New Connection` and pick your database type.
    
3.  02
    
    Enter connection details
    
    Fill in the following fields:
    
    Host: your-db.example.com;
    
    Port: 5432 (PostgreSQL) / 3306 (MySQL);
    
    Database: your\_database\_name;
    
    Username: dashport\_readonly;
    
    Password: ••••••••;
    
4.  03
    
    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`.
    
5.  04
    
    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 SQLChat▶Superdashboard

— skip Chat, your data is already report-ready

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

custom-query-example.sqlsql⧉Copy

```
1-- Monthly revenue by product category — report-ready, no further transformation needed2SELECT3  DATE_TRUNC('month', o.order_date)  AS month,4  p.category                          AS category,5  SUM(oi.quantity * oi.unit_price)    AS revenue,6  COUNT(DISTINCT o.id)                AS order_count,7  ROUND(AVG(oi.unit_price), 2)        AS avg_order_value8FROM orders o9JOIN order_items oi ON oi.order_id = o.id10JOIN products    p  ON p.id = oi.product_id11WHERE o.order_date >= NOW() - INTERVAL '12 months'12  AND o.status = 'completed'13GROUP BY 1, 214ORDER 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

```
1-- Create a dedicated read-only role2CREATE ROLE dashport_readonly WITH LOGIN PASSWORD 'replace_with_strong_password';3 4-- Grant connection access to your database5GRANT CONNECT ON DATABASE your_database TO dashport_readonly;6 7-- Grant usage on the target schema8GRANT USAGE ON SCHEMA public TO dashport_readonly;9 10-- Grant SELECT on all existing tables11GRANT SELECT ON ALL TABLES IN SCHEMA public TO dashport_readonly;12 13-- Grant SELECT on future tables automatically14ALTER DEFAULT PRIVILEGES IN SCHEMA public15  GRANT SELECT ON TABLES TO dashport_readonly;
```

[←Previous · §2.1Supported integrations](/documentation/supported-integrations)[Next · §2.3→Column comments & AI context](/documentation/column-comments-ai-context)

On this page0%

↑ Back to top

## Stuck on a step?

Tell us what you tried and what you expected.

*   [Open a ticket →](/open-ticket)
*   [System status →](/status)
