Skip to content

Commit

Permalink
community[patch]: fix database uri type in SQLDatabase (#22661)
Browse files Browse the repository at this point in the history
**Description**
sqlalchemy uses "sqlalchemy.engine.URL" type for db uri argument.
Added 'URL' type for compatibility.

**Issue**: None

**Dependencies:** None

---------

Co-authored-by: Bagatur <[email protected]>
  • Loading branch information
hyorea1 and baskaryan authored Jun 12, 2024
1 parent 5dbbdcb commit b6bf2bb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libs/community/langchain_community/utilities/sql_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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
Expand Down Expand Up @@ -128,7 +128,10 @@ def __init__(

@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 {}
Expand Down

0 comments on commit b6bf2bb

Please sign in to comment.