Comment on page
Delete all pages from database
Tags: #notion #productivity #naas_drivers #operations #snippet #database
Last update: 2023-04-12 (Created: 2023-01-24)
Description: This notebook deletes all page from a Notion database.
from naas_drivers import notion
- Share integration with your database
# Enter Token API
NOTION_TOKEN = "ENTER_YOUR_NOTION_TOKEN_HERE" # EXAMPLE: "secret_xxxxxxxxxxxxxxxxxx"
# Enter Page URL
DATABASE_URL = "ENTER_YOUR_DATABASE_URL_HERE" # EXAMPLE: "https://www.notion.so/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
def delete_all_pages(database_url, token):
# Get pages
database_id = database_url.split("/")[-1].split("?v=")[0]
pages = notion.connect(token).database.query(database_id, query={})
for page in pages:
notion.connect(token).blocks.delete(page.id)
print(f"{page.id} removed from database")
delete_all_pages(DATABASE_URL, NOTION_TOKEN)
Last modified 3mo ago