Skip to content

Commit

Permalink
refactor: update Notion client integration and database schema retrieval
Browse files Browse the repository at this point in the history
- Replaced the `notion_client.Client` with `notion_automation.notion_client.NotionClient` for improved modularity.
- Updated the authentication method to use `NOTION_API_KEY` instead of `NOTION_TOKEN`.
- Modified the database retrieval method to align with the new client structure, enhancing clarity and maintainability.
  • Loading branch information
atxtechbro committed Dec 22, 2024
1 parent c0717eb commit 9b72b2f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions notion_automation/get_database.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import sys
import json
from notion_client import Client
from notion_automation.notion_client import NotionClient
import os
from dotenv import load_dotenv

def get_database_schema(database_id):
"""Retrieve and format the schema of a Notion database."""
load_dotenv()
notion = Client(auth=os.getenv("NOTION_TOKEN"))
notion = NotionClient(auth_token=os.getenv("NOTION_API_KEY"))

try:
database = notion.databases.retrieve(database_id=database_id)
database = notion.get_database(database_id)

# Extract and format the properties schema
schema = {
"title": database["title"][0]["plain_text"] if database.get("title") else "",
"title": database["title"],
"properties": {}
}

Expand Down

0 comments on commit 9b72b2f

Please sign in to comment.