Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ag/notion source update #242

Merged
merged 6 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading