If you’d like to learn more about how Dreamlit works overall, check out the How
it works page.
Adding a connection
To add a connection:- Go to Settings → Database Connections.
- Click + Add connection.
- Paste your PostgreSQL URL (e.g.,
postgresql://user:password@host:5432/database) into any field. Dreamlit will automatically parse and fill in the required fields. - Verify all details, and configure SSL settings if necessary.
- Click Test Connection to ensure it works before saving.
- Click Save.

Configuration panel for Postgres in the settings connections page
Dreamlit requires an IPv4 compatible connection to your database. To ensure optimal performance, we strongly recommend
using a connection pooler like Pgbouncer in transaction mode and connecting through that instead of directly to your database.
How Dreamlit configures your database
Dreamlit’s notification architecture is optimized for the performance and robustness of your workflows. Your database is minimally instrumented accordingly. The very first time you set up a database connection, Dreamlit creates adreamlit schema (if it doesn’t already exist) and an event_log table
inside it. Then, whenever you publish a workflow containing a Database Trigger step, Dreamlit creates:
- A table trigger on the specified table, which activates whenever a relevant insert or update occurs.
- A trigger function in the
dreamlitschema that runs when the trigger fires, which simply logs a row to thedreamlit.event_logtable indicating that a new event has occurred.
dreamlit.event_log table, and whenever it sees a new row matching an active trigger, it launches the associated workflow.
In addition to the
event_log table, Dreamlit may create other small
housekeeping tables in the dreamlit schema. It never writes to your existing
tables (beyond installing triggers).What's a schema and why does Dreamlit need one in my db?
What's a schema and why does Dreamlit need one in my db?
A schema is a grouping of tables, functions, and other database objects.
It’s a way for you organize your tables, often for security reasons. See here for more.Dreamlit manages its objects in a dedicated schema so that it provides a clean separation between your application and the Dreamlit-managed objects. Dreamlit’s approach allows for events
to be detected in realtime, while ensuring events don’t get lost. This separate schema approach is inspired by
similar techniques used in other tools like Supabase and Hasura.
Permissions needed
The Postgres user provided to Dreamlit must at least have the following permissions:- Read relevant tables (
SELECT). - Create triggers on tables that launch workflows.
- Manage its own
dreamlitschema for housekeeping and logging.
If you’re using a wire-compatible Postgres database, like CockroachDB or
Google Spanner, these steps won’t work for you, as the commands below are
not fully implemented by your database. Instead, please reach out to
us and we can provide custom instructions.
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 ability to create and manage the dreamlit schema
Next, we allow the Dreamlit user to create and manage thedreamlit schema within your database. Be sure to replace <YOUR_DATABASE_NAME> below
with the name of your database (e.g., defaultdb or postgres).
3. Grant view access and trigger creation permissions
Finally, we need to ensure the Dreamlit user has view and trigger creation access to the tables you’d like to build workflows on. Run the commands below for each schema, replacing<YOUR_SCHEMA_NAME> with each schema name (e.g., public).
dreamlit_user 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:
dreamlit_user to SELECT rows.
Run the following command to generate the policy creation commands for all RLS-enabled tables:
4. Construct your new connection string
Construct your PostgreSQL connection string using thedreamlit_user and the <SECRET_PASSWORD> you created. Provide this string to Dreamlit.
Supabase
Supabase
Use the Pooler connection details from your Supabase dashboard. You must add your Project Ref to the username.
- Replace
<YOUR_PROJECT_REF>,<SUPABASE_POOLER_HOST>, and<POOLER_PORT>(usually 6543) with values from your Supabase Database settings.
Neon
Neon
Use the Pooled connection details from your Neon dashboard. The username is just
dreamlit_user.- Replace
<NEON_POOLED_HOST>,<NEON_PORT>, and<NEON_DB_NAME>with values from your Neon Connection Details.
Standard Databases (AWS RDS, Google Cloud, Azure, Heroku, DigitalOcean, Direct Connection)
Standard Databases (AWS RDS, Google Cloud, Azure, Heroku, DigitalOcean, Direct Connection)
Use your standard database connection details.
- Replace
<YOUR_DATABASE_HOST>,<PORT>(usually 5432), and<YOUR_DATABASE_NAME>with your database’s connection details.
Other Connection Poolers (PgBouncer, Pgpool-II)
Other Connection Poolers (PgBouncer, Pgpool-II)
Connect to your pooler’s address. The database name might be an alias defined in the pooler config.
- Replace
<YOUR_POOLER_HOST>,<POOLER_PORT>(e.g., 6432), and<DB_NAME_ALIAS_IN_POOLER>with your pooler’s specific details. Check pooler configuration if unsure.
Commands to remove Dreamlit user
Commands to remove Dreamlit user
If you’d like to drop the
dreamlit_user, you can issue the following commands:Protecting notifications from breaking schema changes
When you make database schema changes, such as renaming or dropping tables or columns, you risk accidentally breaking notifications linked to your Dreamlit workflows. To help you avoid silently breaking notifications, Dreamlit provides two protective options:Option 1: Protective database checks via event triggers
Option 1: Protective database checks via event triggers
You can install a protective event trigger directly in your database.This trigger monitors schema-altering commands (
DROP, ALTER) and cross-references them with metadata stored in a dedicated dreamlit schema table. If the schema object you’re modifying is referenced by an active workflow, the trigger raises an exception and prevents the change.Currently in beta. Reach out to us and we can supply you with the SQL to install the trigger in your database.Option 2: Schema validation in CI
Option 2: Schema validation in CI
Alternatively, you can integrate schema validation as part of your CI process. Dreamlit offers a validation step you can run in your preview or staging environments.This step compares your database schema against the expected schema required by your Dreamlit workflows, catching any potential breaking changes before they reach production.Currently in beta. Reach out to us if you’d like access to this feature.
Making the schema change safely
To ensure a smooth transition to a new schema for an otherwise breaking change, we recommend one of the following approaches:Option 1: Unpublish, change, then publish again
Option 1: Unpublish, change, then publish again
If you don’t mind brief downtime for your workflows, this is the quickest approach.
- Unpublish any workflows referencing the old column/table.
- Apply your schema update.
- Adjust your Dreamlit workflow steps to reference the new schema.
- Publish your workflow again.
Option 2: Phased migration
Option 2: Phased migration
You can follow the “expand, migrate, and contract pattern” to make your schema changes.
- Add new columns or tables.
- Write to both old and new columns from your application.
- Backfill data into the new columns or tables.
- Update your Dreamlit workflow to reference the new columns/tables, and possibly update your application to reference the new columns/tables.
- Remove (or rename) the old columns/tables once no longer needed.
Uninstalling Dreamlit
If you ever want to remove Dreamlit entirely:- Unpublish all workflows that depend on your Postgres connection (this removes triggers/functions).
- Delete the connection in the Dreamlit dashboard.
- (Optional) Drop the
dreamlitschema to remove all Dreamlit-managed objects.
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.