From 7a2fcd9683cb099a0e082994e9214aa17db5eb66 Mon Sep 17 00:00:00 2001 From: Yotam Perlitz Date: Fri, 17 Jan 2025 04:25:41 -0500 Subject: [PATCH] fix acess to db Signed-off-by: Yotam Perlitz --- src/unitxt/db_utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/unitxt/db_utils.py b/src/unitxt/db_utils.py index 299f808e46..d05364be3b 100644 --- a/src/unitxt/db_utils.py +++ b/src/unitxt/db_utils.py @@ -193,9 +193,9 @@ class RemoteDatabaseConnector(DatabaseConnector): def __init__(self, db_config: SQLDatabase): super().__init__(db_config) - assert db_config[ - "db_id" - ], "db_id must be in db_config for RemoteDatabaseConnector" + assert db_config["db_id"], ( + "db_id must be in db_config for RemoteDatabaseConnector" + ) self.api_url, self.database_id = ( db_config["db_id"].split(",")[0], db_config["db_id"].split("db_id=")[-1].split(",")[0], @@ -222,17 +222,17 @@ def get_table_schema( self, ) -> str: """Retrieves the schema of a database.""" - response = requests.post( - f"{self.api_url}/datasource", + cur_api_url = f"{self.api_url}/datasource/{self.database_id}" + response = requests.get( + cur_api_url, headers=self.base_headers, - json={"dataSourceId": self.database_id}, verify=True, timeout=self.TIMEOUT, ) if response.status_code == 200: schema = response.json()["schema"] else: - raise OSError(f"Could not fetch schema from {self.api_url}") + raise OSError(f"Could not fetch schema from {cur_api_url}") schema_text = "" for table in schema["tables"]: