mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-19 11:08:55 +00:00
Fix for syntax when setting search_path for Snowflake database (#4747)
# Fixes syntax for setting Snowflake database search_path An error occurs when using a Snowflake database and providing a schema argument. I have updated the syntax to run a Snowflake specific query when the database dialect is 'snowflake'.
This commit is contained in:
parent
db6f7ed0ba
commit
c06973261a
@ -224,6 +224,11 @@ class SQLDatabase:
|
|||||||
"""
|
"""
|
||||||
with self._engine.begin() as connection:
|
with self._engine.begin() as connection:
|
||||||
if self._schema is not None:
|
if self._schema is not None:
|
||||||
|
if self.dialect == "snowflake":
|
||||||
|
connection.exec_driver_sql(
|
||||||
|
f"ALTER SESSION SET search_path='{self._schema}'"
|
||||||
|
)
|
||||||
|
else:
|
||||||
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