Skip to content

Commit

Permalink
fix acess to db
Browse files Browse the repository at this point in the history
Signed-off-by: Yotam Perlitz <[email protected]>
  • Loading branch information
perlitz committed Jan 17, 2025
1 parent e27e996 commit 7a2fcd9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/unitxt/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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"]:
Expand Down

0 comments on commit 7a2fcd9

Please sign in to comment.