-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.py
More file actions
24 lines (18 loc) · 797 Bytes
/
sync.py
File metadata and controls
24 lines (18 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from notion.client import NotionClient
from datetime import datetime
# Set up the Notion client with your integration token
client = NotionClient(token_v2="")
# Access the database
database_url = "" # your Notion database URL
database = client.get_block(database_url)
# For each event fetched from Google Calendar, add it to the Notion database
for event in events:
title = event['summary']
start_time = event['start'].get('dateTime', event['start'].get('date'))
# Convert the start_time to a format that Notion accepts
start_time = datetime.fromisoformat(start_time.replace("Z", "+00:00"))
# Add the event to the Notion database
new_row = database.collection.add_row()
new_row.name = title
new_row.date = start_time
print("Events added to Notion!")