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 <baskaryan@gmail.com>
This commit is contained in:
HyoJin Kang 2024-06-13 04:11:00 +09:00 committed by GitHub
parent 5dbbdcbf8e
commit b6bf2bb234
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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