Skip to content

Commit 60c3efa

Browse files
saathwik-tkmdrxy
authored andcommitted
Fixed Syntax Error in Trino dialect (#399)
### 🐞 Bug Fix: Trino Schema Selection **Issue:** `connection.exec_driver_sql()` was using a parameterized `USE ?` statement for Trino, which caused schema selection to fail. Trino does not support parameter placeholders for schema commands. **Fix:** Replaced the parameterized query with an f-string formatted command to directly include the schema name. ```python # Before connection.exec_driver_sql( "USE ?", (self._schema,), ) # After connection.exec_driver_sql( f"USE {self._schema}", execution_options=execution_options, ) Co-authored-by: Mason Daugherty <[email protected]>
1 parent da57c9f commit 60c3efa

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

libs/community/langchain_community/utilities/sql_database.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,7 @@ def _execute(
500500
pass
501501
elif self.dialect == "trino":
502502
connection.exec_driver_sql(
503-
"USE ?",
504-
(self._schema,),
503+
f"USE {self._schema}",
505504
execution_options=execution_options,
506505
)
507506
elif self.dialect == "duckdb":

0 commit comments

Comments
 (0)