Skip to content

Commit

Permalink
Ag/notion source update (#242)
Browse files Browse the repository at this point in the history
* Create devcontainer.json

* Deleted dev container

* modified notion source to handle key error for "use_name" not provided.

* Updated Return of get_database function and changed doc strings.

* Removed whitespace from a blank line

* reformated client.py
  • Loading branch information
dat-a-man authored Aug 15, 2023
1 parent 72167d6 commit 3ed20fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sources/notion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def notion_databases(
]

for database in database_ids:
if "use_name" not in database:
# Fetch the database details from Notion
details = notion_client.get_database(database["id"])

# Extract the name/title from the details
database["use_name"] = details["title"][0]["plain_text"]

notion_database = NotionDatabase(database["id"], notion_client)
yield dlt.resource( # type: ignore
notion_database.query(),
Expand Down
11 changes: 11 additions & 0 deletions sources/notion/helpers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,14 @@ def search(
next_cursor = response.get("next_cursor")
has_more = next_cursor is not None
start_cursor = next_cursor

def get_database(self, database_id: str) -> Any:
"""Fetches the details of a specific database by its ID.
Args:
database_id (str): The ID of the database to fetch.
Returns:
Any: The details of the database.
"""
return self.fetch_resource("databases", database_id)

0 comments on commit 3ed20fc

Please sign in to comment.