Metabase_
Connect Metabase to an Appwrite native PostgreSQL database for analytics. Use a read-only PostgreSQL role, configure SSL, and build dashboards on a session-safe connection.
4 min read
Appwrite's native PostgreSQL database is a standard PostgreSQL engine, so Metabase can connect to it without an Appwrite-specific adapter. Add the database in Metabase, point it at the host from the Connections page, and Metabase will sync the schema so your team can build questions and dashboards.
You'll need a native PostgreSQL database in a ready state and its credentials. In the Console, open the database and click Credentials. Copy the individual values from the Details tab, or use the DSN, .env, or psql tab. You can also fetch the same values with postgresql.get(). The primary user is admin, and the database name is generated per database.
Use a read-only PostgreSQL role
Dashboards should not connect as the primary admin user. That role owns the database and can run schema changes. For analytics, create a read-only PostgreSQL role for Metabase from the database Roles tab in the Console, then grant it access only to the schemas and tables Metabase should query.
At minimum, a reporting role needs permission to connect to the database, usage on the schemas you want to expose, and SELECT on the tables and views in those schemas. Use the SQL editor, psql, or your migration workflow to apply the grants after you create the role. See Database roles for how roles work with native PostgreSQL databases.
If you plan to use Metabase features that write data, such as editable table data, use a separate connection with the specific write privileges that feature needs. Keep the analytics connection read-only.
Add the database in Metabase
In Metabase, click the grid icon, then open Admin > Databases > Add a database. Choose PostgreSQL as the database type and fill in the connection form with the values from the Connections page.
| Field | Value |
|---|---|
| Host | db-<hash>.<region>.appwrite.center |
| Port | 5432 |
| Database name | <database> |
| Username | your read-only PostgreSQL role |
| Password | the role password |
Turn on Use a secure connection (SSL) and set SSL Mode to require. Appwrite Cloud requires TLS for native PostgreSQL connections. If you choose verify-ca or verify-full, Metabase also requires a root certificate in PEM format. See Network security for Appwrite TLS and network controls.
Metabase keeps database sessions open and can use session-level PostgreSQL behavior while exploring data. Connect it to the direct PostgreSQL port (5432) or to the connection pooler in session mode. Transaction-mode pooling can break session-level features because a client session is not bound to one backend connection.
Click Save changes. Metabase verifies the connection and starts its first schema sync.
Build a question or dashboard
Once the first sync finishes, your tables appear in the data picker. To build your first chart:
- Click + New > Question and pick your Appwrite PostgreSQL database as the data source.
- Choose a table, add a summary such as count, sum, or average, and group by a column such as a timestamp.
- Switch the visualization to a line, bar, or table view, then save the question.
- Add saved questions to a dashboard and use filters to slice data across cards.
Because the analytics connection is read-only, native SQL questions can inspect data without changing it. Queries that attempt writes will fail unless you intentionally connect Metabase with a role that has write privileges.
How Metabase syncs your schema
After you connect, Metabase scans the database to discover tables, columns, constraints, and field metadata, then keeps that metadata current on a schedule:
- A lightweight schema sync runs hourly by default.
- A more intensive field-value scan runs daily by default to populate filter dropdowns.
New tables and columns appear after the next sync. To pull them in immediately, open Admin > Databases > your database and click Sync database schema. You can also restrict which schemas Metabase tracks and adjust the sync and scan cadence from the database settings. Refer to the Metabase documentation for the full set of sync and scan options.
Use a branch for testing
Branches are isolated copies of a native PostgreSQL database with their own host and credentials. Point a second Metabase database connection at a branch when you want to validate a dashboard against a snapshot of production data without querying the live database. Branches are managed through the API, and you can delete the branch when testing is complete.
Related
PostgreSQL
Provision and manage a native PostgreSQL database for your project.
Connections
Retrieve credentials, rotate the primary password, and manage PostgreSQL roles.
Connection pooling
Pool modes and ports, including why BI tools need session or direct connections.
Network security
TLS, certificate verification, IP allowlists, and idle connection timeouts.
Was this page helpful?
Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.