This article covers all the required steps to to connect to and query a Supabase Postgres database through DataLab. This enables you to:

  • Analyze the data in the Supabase database, like user growth or daily number of sessions. Which data or processes you want to analyze will depend on the application that Supabase is powering.

  • Automate reporting: you can use the "Schedule run" functionality to rerun your analysis on a schedule so that your report always takes in the latest available data as your app is being used.

The steps below and some sample code are also available in this workbook (click this link to create your own copy).


Create a supabase project

If you don't have a Supabase project yet, go to [](, create a free account, start a new project, and follow all the instructions. When setting a database password, make sure to store it somewhere, as you'll need to use this in the next step.

Locate your database credentials

Every Supabase project is powered by a Postgres database. To find the credentails of this database, from the Supabase dashboard, click the cog icon ("Settings") and select "Database". You'll see all the credentials you need:

Connect to the database

In DataLab, head over to your databases overview, click "Connect a database" and select "Postgres".

Configure the connection:

  • Database connection name can be anything; give it a meaningful name.

  • Hostname, port, database and username: copy these over from the credentials you found in Supabase in the previous step.

  • Password: Set this to the password that you provided when setting up the Supabase project in the first step.

  • Make sure to check "Encrypt connection".

Click "Connect".

You're all set now!!

Query your Supabase data

  • Create a new workbook.

  • Add a SQL cell, select the Supabase database connection that you created.

  • Write and execute a query, e.g. SELECT * FROM auth.sessions

Further reading

For a deeper dive on Supabase, check out its documentation.

Last updated