Last active
November 27, 2022 10:56
-
-
Save jskherman/e589135e79dfdeed74e75d4ff756abd5 to your computer and use it in GitHub Desktop.
Add a new row in a Notion database using python via notion-df
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import packages | |
import os | |
import dotenv # for .env files | |
import datetime | |
import requests | |
import pandas as pd | |
# Do `pip install notion-df` first | |
import notion_df | |
# Set up environment variables for authentication | |
# dotenv.load_dotenv() # Uncomment if using a .env file | |
notion_df.config(api_key=os.environ["NOTION_API_KEY"]) | |
# Specify the url to the database | |
# Share > Copy link (in the upper-right corner of the page) | |
notion_db_url = "https://www.notion.so/username/b7d4912d52764d279fbab12317069981?v=d0b75072fef7422f9e81703046138f89" | |
# Specify the content to be added | |
new_row_content = { | |
"Field1": value1, | |
"Field2": value2, | |
"Field3": value3, | |
} | |
new_row = pd.DataFrame(new_row_content, index=[0]) | |
notion_df.upload(new_row, notion_db_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment