forked from Archives/langchain
dont error on sql import (#4647)
this makes it so we dont throw errors when importing langchain when sqlalchemy==1.3.1 we dont really want to support 1.3.1 (seems like unneccessary maintance cost) BUT we would like it to not terribly error should someone decide to run on it
This commit is contained in:
parent
c9a362e482
commit
d5a0704544
@ -3,7 +3,8 @@ import logging
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from sqlalchemy import Column, Integer, Text, create_engine
|
from sqlalchemy import Column, Integer, Text, create_engine
|
||||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
from langchain.schema import (
|
from langchain.schema import (
|
||||||
AIMessage,
|
AIMessage,
|
||||||
|
@ -13,7 +13,7 @@ from sqlalchemy import (
|
|||||||
select,
|
select,
|
||||||
text,
|
text,
|
||||||
)
|
)
|
||||||
from sqlalchemy.engine import CursorResult, Engine
|
from sqlalchemy.engine import Engine
|
||||||
from sqlalchemy.exc import ProgrammingError, SQLAlchemyError
|
from sqlalchemy.exc import ProgrammingError, SQLAlchemyError
|
||||||
from sqlalchemy.schema import CreateTable
|
from sqlalchemy.schema import CreateTable
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ class SQLDatabase:
|
|||||||
try:
|
try:
|
||||||
# get the sample rows
|
# get the sample rows
|
||||||
with self._engine.connect() as connection:
|
with self._engine.connect() as connection:
|
||||||
sample_rows_result: CursorResult = connection.execute(command)
|
sample_rows_result = connection.execute(command) # type: ignore
|
||||||
# shorten values in the sample rows
|
# shorten values in the sample rows
|
||||||
sample_rows = list(
|
sample_rows = list(
|
||||||
map(lambda ls: [str(i)[:100] for i in ls], sample_rows_result)
|
map(lambda ls: [str(i)[:100] for i in ls], sample_rows_result)
|
||||||
|
@ -8,7 +8,8 @@ from typing import Any, Dict, Iterable, List, Optional, Tuple
|
|||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import REAL, Index
|
from sqlalchemy import REAL, Index
|
||||||
from sqlalchemy.dialects.postgresql import ARRAY, JSON, UUID
|
from sqlalchemy.dialects.postgresql import ARRAY, JSON, UUID
|
||||||
from sqlalchemy.orm import Session, declarative_base, relationship
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.orm import Session, relationship
|
||||||
from sqlalchemy.sql.expression import func
|
from sqlalchemy.sql.expression import func
|
||||||
|
|
||||||
from langchain.docstore.document import Document
|
from langchain.docstore.document import Document
|
||||||
|
Loading…
Reference in New Issue
Block a user