mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Fixing issue with MSSQL connection (#8040)
My team recently faced an issue while using MSSQL and passing a schema name. We noticed that "SET search_path TO {self.schema}" is being called for us, which is not a valid ms-sql query, and is specific to postgresql dialect. We were able to run it locally after this fix. --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
76102971c0
commit
1f055775f8
@ -383,7 +383,9 @@ class SQLDatabase:
|
|||||||
)
|
)
|
||||||
elif self.dialect == "bigquery":
|
elif self.dialect == "bigquery":
|
||||||
connection.exec_driver_sql(f"SET @@dataset_id='{self._schema}'")
|
connection.exec_driver_sql(f"SET @@dataset_id='{self._schema}'")
|
||||||
else:
|
elif self.dialect == "mssql":
|
||||||
|
pass
|
||||||
|
else: # postgresql and compatible dialects
|
||||||
connection.exec_driver_sql(f"SET search_path TO {self._schema}")
|
connection.exec_driver_sql(f"SET search_path TO {self._schema}")
|
||||||
cursor = connection.execute(text(command))
|
cursor = connection.execute(text(command))
|
||||||
if cursor.returns_rows:
|
if cursor.returns_rows:
|
||||||
|
Loading…
Reference in New Issue
Block a user