Deepnote offers a collaborative data notebook that allows users to connect to a PostgreSQL database (such as and write queries on that database connection right in the notebook cells. Additionally, the connection details are saved as environment variables in the notebook environment, so they can be used to configure connections with e.g. psycopg2 in Python.

Connecting to with Deepnote

After you've signed up for Deepnote and created a new notebook, click "Integrations" in the left sidebar, and then click "PostgreSQL."


Fill in your connection credentials from your Connect Tab.


Return to your notebook. From the right sidebar, select the integration you just made in the "integrations" tab (it will show up as whatever you put into "Integration name") and click "connect." This will trigger a restart of your notebook.


Using Deepnote with

Once you've set up a PostgreSQL integration to your database, you can create SQL cells in your notebook and query the database you connected to with the PostgreSQL integration. You can also choose to save the results of those queries to variables which you can access in python cells in the same notebook.


For more information, refer to the Deepnote documentation on PostgreSQL integrations.