diff --git a/sources/notion/__init__.py b/sources/notion/__init__.py index 9dcbb0933..0e3f98718 100644 --- a/sources/notion/__init__.py +++ b/sources/notion/__init__.py @@ -39,6 +39,15 @@ 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 + # This depends on the structure of the response from Notion. + # Here, I'm assuming the title is stored similarly to your earlier logic. + database["use_name"] = details["title"][0]["plain_text"] + notion_database = NotionDatabase(database["id"], notion_client) yield dlt.resource( # type: ignore notion_database.query(), diff --git a/sources/notion/helpers/client.py b/sources/notion/helpers/client.py index ef4bd3fa5..78767001a 100644 --- a/sources/notion/helpers/client.py +++ b/sources/notion/helpers/client.py @@ -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) -> Dict[str, Any]: + """Fetches the details of a specific database by its ID. + + Args: + database_id (str): The ID of the database to fetch. + + Returns: + Dict[str, Any]: The details of the database. + """ + return self.fetch_resource("databases", database_id) \ No newline at end of file