Update page
This notebook shows how to use Naas Notion driver to update a page (properties + content) inside a database.
Tags: #notion #productivity #naas_drivers
Author: Maxime Jublou

Input

Import libraries

1
from naas_drivers import notion
Copied!

Input variables

1
# Enter Token API
2
token = "*****"
3
4
# Enter Database URL
5
page_url = "https://www.notion.so/naas-official/Daily-med-03952fcb93c045bba519a7564a64045e"
Copied!

Model

Get page

Get your page content and returns a dataframe with name of column, type and value.
1
page = notion.connect(token).page.get(page_url)
2
page
Copied!

Update page properties

Properties are associated with the database. If you put a page type that is not currently present, it will create it.
1
page.title("Name","Page updated")
2
page.rich_text("Text","Ceci est toto")
3
page.number("Number", 42)
4
page.select("Select","Value3")
5
page.multi_select("Muti Select",["Value1","Value2","Value3"])
6
page.date("Date","2021-10-03T17:01:26") #Follow ISO 8601 format
7
page.people("People", ["6e3bab71-beeb-484b-af99-ea30fdef4773"]) #list of ID of users
8
page.checkbox("Checkbox", False)
9
page.email("Email","[email protected]")
10
page.phone_number("Phone number","+33 6 21 83 11 12")
11
page.update()
Copied!

Update page blocks

Blocks are the content of the page.
1
page.heading_1("Heading 1")
2
page.heading_2("Heading 2")
3
page.heading_3("Heading 3")
4
page.paragraph("Paragraph")
5
page.numbered_list_item("This is first")
6
page.to_do("Need this to be done")
7
page.embed("https://docs.google.com/spreadsheets/*************")
8
page.video("https://www.youtube.com/watch?v=8AsMAc4VFJs")
9
page.image("https://landen.imgix.net/jtci2pxwjczr/assets/5ice39g4.png")
10
page.code("pip install naas")
11
page.equation("e=mc2")
12
page.update()
Copied!

Output

1
page
Copied!
Copy link
Edit on GitHub