From 1fa056c324ccc8bee2c07a397653e653fb68d52d Mon Sep 17 00:00:00 2001 From: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com> Date: Wed, 17 Jan 2024 23:31:11 +0500 Subject: [PATCH] community[patch]: Don't set search path for unknown SQL dialects (#16047) - **Description:** Made a small fix for the `SQLDatabase` highlighted in an issue. The issue pertains to switching schema for different SQL engines. - **Issue:** #16023 @baskaryan --- libs/community/langchain_community/utilities/sql_database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/utilities/sql_database.py b/libs/community/langchain_community/utilities/sql_database.py index 9f665b7132..8379fbc337 100644 --- a/libs/community/langchain_community/utilities/sql_database.py +++ b/libs/community/langchain_community/utilities/sql_database.py @@ -409,8 +409,9 @@ class SQLDatabase: # If anybody using Sybase SQL anywhere database then it should not # go to else condition. It should be same as mssql. pass - else: # postgresql and other compatible dialects + elif self.dialect == "postgresql": # postgresql connection.exec_driver_sql("SET search_path TO %s", (self._schema,)) + cursor = connection.execute(text(command)) if cursor.returns_rows: if fetch == "all":