This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.
With Dash Enterprise, you have access to managed Postgres databases for your apps. Postgres is well-suited for many Dash apps. In particular, you can use Postgres to:
Postgres instances are app-specific. Each app can have one Postgres instance. To use Postgres with an app, add it after you’ve created the app:
Once you add Postgres to an app, you can access Postgres in your app code in Dash Enterprise with:
connection_string = os.environ.get("DATABASE_URL")
For running Postgres locally on your own workstation, supply the local URL to be used outside of Dash Enterprise:
connection_string = os.environ.get("DATABASE_URL", <LOCAL_DATABASE_URL>)
<LOCAL_DATABASE_URL> with the URL of the database that you are running locally. For example, on Mac with the Postgres app, this might be ‘postgres://postgres:firstname.lastname@example.org:5432’
If you are using the pg8000 driver, then this URL can be prefixed with pg8000+.
connection_string = "postgres+pg8000" + os.environ.get("DATABASE_URL", "postgres://postgres:email@example.com:5432").lstrip("postgres")
The pg8000 driver is easy to install but isn’t production ready.
Not all versions of
sqlalchemy, and Postgres libraries like
pg8000 are compatible. Here are some combinations we know to work well together:
pandas==1.4.1 psycopg2-binary==2.8.6 sqlalchemy==1.4.31
pandas==1.1.5 pg8000==1.16.5 SQLAlchemy==1.3.20
Dash Enterprise Workspaces share the same Postgres instance as your deployed
app. This allows you to inspect your Postgres instance’s data from that app’s workspace.
Since these databases are shared, be careful when writing or deleting data from Postgres in a Workspace!
After adding Postgres to an app, you’ll need to restart Workspaces to have access to that database.
To test your app locally, you’ll need to install and start Postgres.
Homebrew is a package manager for MacOS and makes it easy to install packages, including Postgres. This is the quickest way to get up and running developing with Postgres locally on a Mac.
shell brew install postgresql
shell brew services start postgres
shell psql postgres
Once you’re finished using Postgres, you can stop the server with
brew services stop postgres.
You’ll find instructions for other OS and installers on the PostgreSQL site.
To delete an app’s Postgres service:
Find and select the app in the App Manager.
Select the Services tab.
Select the Postgres service. (The name ends in -postgres).
Select Remove. You are prompted to enter the service-name to confirm.
Dash Enterprise 5 uses Postgres version 14 from Docker Hub and its default settings. Right now it’s not possible to configure the settings.
Each Postgres instance has a maximum storage capacity of 25 GiB. Additionally, the number of services (Postgres or Redis) that you can have across Dash Enterprise is limited by the number of pods and volumes allowed per node by your Kubernetes cloud provider and the number of nodes in your cluster.
If you are an administrator with access to the Kubernetes cluster that Dash Enterprise is installed on, you can view logs for an app’s Postgres service by connecting to the cluster.
Managed database services are located in the
dash-services namespace. To view logs for an app’s Postgres service, make sure your
kubectl context is set to the right cluster, and then run the following command:
kubectl logs -f -n dash-services -l app=postgres-<app-name>
<app-name> is the name of the app whose Postgres logs you want to view.