Skip to content

Commit

Permalink
dont error on sql import (#4647)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hwchase17 authored May 18, 2023
1 parent c9a362e commit d5a0704
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion langchain/memory/chat_message_histories/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from typing import List

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 (
AIMessage,
Expand Down
4 changes: 2 additions & 2 deletions langchain/sql_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
select,
text,
)
from sqlalchemy.engine import CursorResult, Engine
from sqlalchemy.engine import Engine
from sqlalchemy.exc import ProgrammingError, SQLAlchemyError
from sqlalchemy.schema import CreateTable

Expand Down Expand Up @@ -196,7 +196,7 @@ def _get_sample_rows(self, table: Table) -> str:
try:
# get the sample rows
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
sample_rows = list(
map(lambda ls: [str(i)[:100] for i in ls], sample_rows_result)
Expand Down
3 changes: 2 additions & 1 deletion langchain/vectorstores/analyticdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import sqlalchemy
from sqlalchemy import REAL, Index
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 langchain.docstore.document import Document
Expand Down

0 comments on commit d5a0704

Please sign in to comment.