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'.
searx_updates
Aidan Boland 1 year ago committed by GitHub
parent db6f7ed0ba
commit c06973261a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -224,7 +224,12 @@ class SQLDatabase:
"""
with self._engine.begin() as connection:
if self._schema is not None:
connection.exec_driver_sql(f"SET search_path TO {self._schema}")
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}")
cursor = connection.execute(text(command))
if cursor.returns_rows:
if fetch == "all":

Loading…
Cancel
Save