Skip to content

Commit

Permalink
remove compulsory requirement to add "database" field to sqlserver
Browse files Browse the repository at this point in the history
  • Loading branch information
rishsriv committed Sep 16, 2024
1 parent bce1361 commit 50aeb9a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 5 deletions.
2 changes: 0 additions & 2 deletions defog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ def check_db_creds(db_type: str, db_creds: dict):
elif db_type == "sqlserver":
if "server" not in db_creds:
raise KeyError("db_creds must contain a 'server' key.")
if "database" not in db_creds:
raise KeyError("db_creds must contain a 'database' key.")
if "user" not in db_creds:
raise KeyError("db_creds must contain a 'user' key.")
if "password" not in db_creds:
Expand Down
2 changes: 1 addition & 1 deletion defog/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def execute_query_once(db_type: str, db_creds, query: str):
except:
raise Exception("pyodbc not installed.")

if db_creds["database"] != "":
if "database" in db_creds and db_creds["database"] != "":
connection_string = f"DRIVER={{ODBC Driver 18 for SQL Server}};SERVER={db_creds['server']};DATABASE={db_creds['database']};UID={db_creds['user']};PWD={db_creds['password']};TrustServerCertificate=yes;Connection Timeout=120;"
else:
connection_string = f"DRIVER={{ODBC Driver 18 for SQL Server}};SERVER={db_creds['server']};UID={db_creds['user']};PWD={db_creds['password']};TrustServerCertificate=yes;Connection Timeout=120;"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def package_files(directory):
name="defog",
packages=find_packages(),
package_data={"defog": ["gcp/*", "aws/*"] + next_static_files},
version="0.65.17",
version="0.65.19",
description="Defog is a Python library that helps you generate data queries from natural language questions.",
author="Full Stack Data Pte. Ltd.",
license="MIT",
Expand Down
1 change: 0 additions & 1 deletion tests/test_defog.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def test_check_db_creds_mongo(self):
def test_check_db_creds_sqlserver(self):
db_creds = {
"server": "some_server",
"database": "some_database",
"user": "some_user",
"password": "some_password",
}
Expand Down

0 comments on commit 50aeb9a

Please sign in to comment.