From b6bf2bb234c1bf631920541a4cdac3e36a4e00de Mon Sep 17 00:00:00 2001 From: HyoJin Kang Date: Thu, 13 Jun 2024 04:11:00 +0900 Subject: [PATCH] community[patch]: fix database uri type in SQLDatabase (#22661) **Description** sqlalchemy uses "sqlalchemy.engine.URL" type for db uri argument. Added 'URL' type for compatibility. **Issue**: None **Dependencies:** None --------- Co-authored-by: Bagatur --- .../langchain_community/utilities/sql_database.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/utilities/sql_database.py b/libs/community/langchain_community/utilities/sql_database.py index ace89c1d03..fa57ea60ff 100644 --- a/libs/community/langchain_community/utilities/sql_database.py +++ b/libs/community/langchain_community/utilities/sql_database.py @@ -14,7 +14,7 @@ from sqlalchemy import ( select, text, ) -from sqlalchemy.engine import Engine, Result +from sqlalchemy.engine import URL, Engine, Result from sqlalchemy.exc import ProgrammingError, SQLAlchemyError from sqlalchemy.schema import CreateTable from sqlalchemy.sql.expression import Executable @@ -128,7 +128,10 @@ class SQLDatabase: @classmethod def from_uri( - cls, database_uri: str, engine_args: Optional[dict] = None, **kwargs: Any + cls, + database_uri: Union[str, URL], + engine_args: Optional[dict] = None, + **kwargs: Any, ) -> SQLDatabase: """Construct a SQLAlchemy engine from URI.""" _engine_args = engine_args or {}