Notion to PostgreSQL
Load data from Notion into PostgreSQL using Bruin's ingestr asset type - automate your Notion data pipeline in minutes.
What is this? A step-by-step tutorial for loading Notion data into a PostgreSQL database using Bruin. Notion is great for organizing information, but when you need to run analytics or join it with other data, a structured database like PostgreSQL is the way to go. Bruin automates this data movement with minimal configuration.
What you'll learn: How to create a Bruin project, define an ingestr asset to pull data from Notion, configure source and destination connections, and run the pipeline.
What you'll build: A pipeline that extracts data from a Notion database and loads it into a PostgreSQL table, ready for querying and analysis.
Full tutorial
Below is the complete tutorial you can read through, or use the step-by-step version above.
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
ingestrfor 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
- Bruin CLI installed
- Notion API credentials
- A PostgreSQL database with connection credentials