Skip to main content
Using cloud-hosted Supabase? This guide is for generic PostgreSQL connections (including self-hosted Supabase). If you’re on Supabase’s cloud platform, use the Supabase guide instead for a one-click OAuth2 setup.
Dreamlit integrates with any PostgreSQL-compatible database (including self-hosted Supabase, Neon, RDS, Cloud SQL, Render, Railway, etc.), letting you trigger notification workflows from database events.

How Dreamlit interacts with your database

On a high level, Dreamlit needs to know where your data lives in your database, install database triggers (for database trigger workflows), and manage some housekeeping tables in a separate schema. This way:
  • Dreamlit’s AI can propose the relevant workflows for you by introspecting your database structure to understand the shape of your data and where it lives.
  • You can preview your workflows with live database rows.
  • You can react to new events happening in your app in real-time.
Dreamlit never edits, deletes, inserts, or otherwise modifies data in your database. For a full technical deep dive, check out the how it works page.
Dreamlit takes security seriously. To review all the measures we take, see Security.

Permissions needed

The Postgres user/role you provide to Dreamlit must at least have the following permissions:
  • Read relevant tables (SELECT) so Dreamlit’s AI can set up workflows for you and you can preview workflows with live database rows.
  • Create triggers on tables to launch workflows right away when events occur.
  • Manage its own dreamlit schema for housekeeping and logging.
Dreamlit does not need edit, delete, or insert permissions on your tables as it never mutates or modifies your data. Of course, if you already have a user with sufficient privileges (such as a superuser) you can use that. However, it is best practice to create a separate Postgres user for each service that needs access to your database, following the principles of isolation and least privilege. Instructions to do this are below.

Commands to run to set up your dreamlit_app database user

It’s recommended to create a separate Postgres database user for each service that needs access to your database.This way, you can grant only the necessary permissions for each service and you can selectively revoke access as needed.
Dreamlit needs the permissions as outlined in the previous section. Follow the instructions below to set up the dreamlit_app user and grant the necessary permissions.
  1. Generate a strong, unique password on your own (e.g., with a password generator).
  2. Fill in the details for your database connection in the applet below. For the host, use your provider’s direct database host (typically port 5432), not a transaction pooler host.
  3. Hit Generate.
  4. Copy the SQL commands and run them in your database as a superuser (e.g., postgres or neondb_owner), substituting [[REPLACE_WITH_PASSWORD]] with your password from step 1 with single quotes like 'mypassword'. This creates the dreamlit_app user and grants the minimal necessary permissions.
  5. Copy the connection string (after replacing the password placeholder, this time without single quotes) into Dreamlit to connect your database and finish setup.
If you’re using RLS (row level security), be sure to turn on the Add RLS policies option in Advanced configuration in the applet above so that the dreamlit_app can SELECT rows on RLS-enabled application tables.For any application tables you create in the future, you will need to ensure there is an appropriate RLS policy created for the dreamlit_app to SELECT rows, by either adding policies manually or rerunning the generator above (the commands generated are idempotent, so you can rerun them as needed).
Run these SQL commands in your database as a superuser (e.g., postgres), or ideally as the same role that creates schemas/tables in your app so default privileges attach to future schemas:

1. Create a dedicated Dreamlit user

First, we create a new database user specifically for Dreamlit with a secure password. Be sure to replace <SECRET_PASSWORD> below with a strong, unique password.

2. Grant database-level privileges

Grant the Dreamlit user basic database access. Be sure to replace <YOUR_DATABASE_NAME> below with the name of your database (e.g., defaultdb or postgres).

3. Install pgcrypto (required)

gen_random_uuid() is used by Dreamlit’s housekeeping objects. Install the extension in the target database:

4. Grant view + trigger permissions on your application tables

Grant the Dreamlit user access to your schemas and set default privileges so future tables work too. Replace <YOUR_SCHEMA_NAME> with each schema (e.g., public) and <TABLE_CREATOR_ROLE> with the role that creates future tables (your migrations/app owner). Two knobs:
  • Scope: run the GRANT block for each schema you want to expose. If you prefer “all schemas”, run the backfill block below once.
  • Future objects: global default privileges (shown here) apply to all future schemas/objects created by <TABLE_CREATOR_ROLE>. If you prefer schema-scoped defaults, swap the global lines for ... IN SCHEMA <YOUR_SCHEMA_NAME> ....
Optional: Sync existing schemas Run this once as the table owner (e.g., postgres) to backfill grants across all existing schemas (grants on current objects; use this if you chose “all schemas” or want to catch up existing ones). Global defaults above already cover future objects; remove the global lines if you prefer per-schema defaults and swap in IN SCHEMA ... per your needs.
Run this query to see which role owns your existing tables:
Use the role name from the tableowner column in the ALTER DEFAULT PRIVILEGES commands above.
If any of your application tables have RLS enabled (common for self-hosted Supabase projects if you use the “anon” role), you must create policies that allow the newly created dreamlit_app to SELECT rows. Otherwise, you won’t be able to read the data needed for your Dreamlit workflows.If you’re not sure, you can run the following command to check which tables have RLS enabled:
If the above query returns any rows, then you have RLS enabled and you’ll need to create a policy for each table that allows the dreamlit_app to SELECT rows.Run the following command to generate the policy creation commands for all RLS-enabled tables:
Finally, copy and execute the commands returned from the above query.For future tables: Unfortunately, PostgreSQL doesn’t support default RLS policies like it does for privileges. You’ll need to remember to create a policy whenever you add a new table with RLS enabled.Dreamlit provisions its own internal dreamlit schema separately during connection setup, so you only need to think about RLS for your application tables here.

5. Construct your new connection string

Construct your PostgreSQL connection string using the dreamlit_app and the <SECRET_PASSWORD> you created. Provide this string to Dreamlit.
Use the direct connection details from your self-hosted Supabase instance.
  • Replace <YOUR_SUPABASE_HOST> with your self-hosted Supabase database host.
Use the Direct connection details from your Neon dashboard. The username is dreamlit_app.
  • Replace <NEON_DIRECT_HOST> and <NEON_DB_NAME> with values from your Neon Connection Details.
Use your standard direct database connection details.
  • Replace <YOUR_DATABASE_HOST>, <PORT> (usually 5432), and <YOUR_DATABASE_NAME> with your database’s connection details.
Copy the correctly formatted connection string and paste it into the Dreamlit connection setup field.

Troubleshooting

If you see an error like permission denied for table X or must be owner of relation X when Dreamlit tries to create triggers, it means the Dreamlit user lacks TRIGGER permission (or ownership) on that table.Quick checks:
  • Confirm Postgres version is 14+ (TRIGGER privilege is grantable starting in 14).
  • Verify the grant actually landed: SELECT has_table_privilege('dreamlit_app','<SCHEMA>.<TABLE>','TRIGGER');
Solution (pick one):
If you see permission denied for schema dreamlit, the schema privileges were not applied correctly.Fix (run as the schema owner or a superuser):
  1. Find who owns the schema:
  1. Easiest path: make dreamlit_app the owner so it can self-manage:
  1. If you must keep the current owner, grant explicit rights to dreamlit_app:
  1. Keep future objects accessible (replace <SCHEMA_OWNER> with the owner from step 1):
This appears when Dreamlit tries to create its internal table but a prior install left dreamlit.event_log owned by another role (or with different grants).Fix (pick one, run as schema owner/superuser):
  1. Reuse the existing table by granting Dreamlit access:
  1. If you prefer Dreamlit to own the table (and the data inside is only Dreamlit logs), transfer ownership:
  1. If it’s safe to rebuild the log (non-production or you don’t need the old rows), drop and let Dreamlit recreate:
After any option, rerun Test Connection. If you keep a non-Dreamlit owner, also set default privileges so new Dreamlit objects stay accessible:
If Dreamlit reports zero rows in all tables, it might be because you have RLS enabled and you haven’t added a SELECT policy for dreamlit_app.Fix: add the right RLS policy for the application tables Dreamlit needs to read.
  • For application tables, rerun the generator above with Add RLS policies enabled in Advanced configuration (or add SELECT policies manually) so dreamlit_app can read data.
  • For new RLS application tables you create later, add a SELECT policy for dreamlit_app or rerun the generator.

Uninstalling Dreamlit

If you ever want to remove Dreamlit entirely:
  1. Unpublish all workflows that depend on your database connection (this removes triggers/functions).
  2. Delete the connection in the Dreamlit dashboard.
  3. (Optional) Drop the dreamlit schema and the dreamlit_app database user to remove all Dreamlit-managed objects.
If you’d like to drop the dreamlit_app role, you can issue the following commands. Replace <YOUR_DATABASE_NAME>, <YOUR_SCHEMA_NAME>, and <TABLE_CREATOR_ROLE> as appropriate. For credential rotation only, skip the optional DROP steps and just update the role password instead.
That’s it! By connecting Postgres to Dreamlit, you can create powerful, real-time workflows triggered by database changes — without writing any custom code in your application.