Update pages from database
Tags: #notion #productivity #naas_drivers
Author: Maxime Jublou

Input

Import library

1
from naas_drivers import notion
Copied!

Setup Notion

1
# Enter Token API
2
notion_token = "*****"
3
4
# Enter Database URL
5
database_url = "https://www.notion.so/********"
Copied!

Model

Get pages from Notion DB

1
database_id = database_url.split("/")[-1].split("?v=")[0]
2
pages = notion.connect(notion_token).database.query(database_id, query={})
3
print("📊 Pages in Notion DB:", len(pages))
Copied!

Output

Update pages

1
for page in pages:
2
print(page)
3
# page.title("Name","Page updated")
4
# page.rich_text("Text","Ceci est toto")
5
# page.number("Number", 42)
6
# page.select("Select","Value3")
7
# page.multi_select("Muti Select",["Value1","Value2","Value3"])
8
# page.date("Date","2021-10-03T17:01:26") #Follow ISO 8601 format
9
# page.people("People", ["6e3bab71-beeb-484b-af99-ea30fdef4773"]) #list of ID of users
10
# page.checkbox("Checkbox", False)
11
# page.email("Email","[email protected]")
12
page.update()
13
print(f"✅ Page updated in Notion.")
Copied!
Copy link
Edit on GitHub