Skip to content

Commit

Permalink
fix(sql): update comment and test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanSaleem committed Jan 31, 2025
1 parent 51dac82 commit 8b29e2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pandasai/data_loader/sql_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def execute_query(self, query: str, params: Optional[list] = None) -> pd.DataFra

except ModuleNotFoundError as e:
raise ImportError(
f"{source_type.capitalize()} connector not found. Please install the pandasai_sql[{source_type}] library.e.g. `pip install pandasai_sql[{source_type}]`"
f"{source_type.capitalize()} connector not found. Please install the pandasai_sql[{source_type}] library, e.g. `pip install pandasai_sql[{source_type}]`."
) from e

except Exception as e:
Expand Down
7 changes: 5 additions & 2 deletions tests/unit_tests/data_loader/test_sql_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,12 @@ def test_mysql_malicious_with_no_import(self, mysql_schema):
)
)
mocked_exec_function.return_value = mock_df
mock_loader_function.side_effect = ModuleNotFoundError("Error")

mock_exec_function = MagicMock()
mock_loader_function.return_value = mock_exec_function
mock_exec_function.side_effect = ModuleNotFoundError("Error")
loader = SQLDatasetLoader(mysql_schema, "test/users")
mock_sql_query.return_value = False
mock_sql_query.return_value = True
logging.debug("Loading schema from dataset path: %s", loader)
with pytest.raises(ImportError):
loader.execute_query("select * from users")

0 comments on commit 8b29e2c

Please sign in to comment.