Bruin Academy

Tutorial module

Notion to PostgreSQL

Load data from Notion into PostgreSQL using Bruin's ingestr asset type - automate your Notion data pipeline in minutes.

Load data from a Notion database into PostgreSQL using Bruin's ingestr asset type. Notion is great for organizing information, but when you need analytics or joins with other data, a structured database is the way to go.

What

  • Create a Bruin project with a Notion-to-PostgreSQL ingestr asset
  • Configure source (Notion API) and destination (PostgreSQL) connections
  • Run the pipeline and verify data in your database

How

  • bruin init default scaffolds the project
  • Define an ingestr asset with source and destination connections in YAML
  • bruin run . extracts Notion data and loads it into PostgreSQL

Create a Bruin project

Initialize a new project:

bruin init default notion-pipeline

This creates a project structure with an assets folder, .bruin.yml for connection and credential management, and pipeline.yml for pipeline configuration.

Create the asset

Add a new file called notion.asset.yml inside the assets folder:

name: public.notion
type: ingestr
connection: my-postgres
parameters:
  source_connection: my-notion
  source_table: 'your_notion_database_id'
  destination: postgres

Key fields:

  • name - The destination table name (e.g. public.notion)
  • type - Use ingestr for Notion sources
  • connection - The name of your PostgreSQL connection
  • source_connection - The name of your Notion connection
  • source_table - Your Notion database ID (found in the URL of your Notion database)

Configure connections

Make sure you have your Notion credentials and PostgreSQL credentials ready.

Add both connections to .bruin.yml:

environments:
  default:
    connections:
      postgres:
        - name: "my-postgres"
          host: "your-host"
          port: 5432
          database: "your-database"
          username: "your-username"
          password: "your-password"
      notion:
        - name: "my-notion"
          api_key: "your-notion-api-key"

Or use bruin connections add to add them interactively.

Configure the pipeline

Edit pipeline.yml to set a schedule and default connections:

name: notion-pipeline
schedule: daily
default_connections:
  postgres: "my-postgres"
  notion: "my-notion"

Run the pipeline

Validate first, then run:

bruin validate .
bruin run .

Verify the results

Your Notion data is now loaded into PostgreSQL. Connect to your database and query the table:

SELECT * FROM public.notion LIMIT 10;

The data from your Notion database is now available as a structured PostgreSQL table, ready for analytics, joins with other tables, or further transformations.

Before you start

Get help & contribute