Skip to content

Commit 40bcf25

Browse files
committed
CrateDB: SQLAlchemyLoader has been superseded by SQLDatabaseLoader
1 parent 062bdaf commit 40bcf25

File tree

8 files changed

+32
-627
lines changed

8 files changed

+32
-627
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from langchain_community.document_loaders.sqlalchemy import SQLAlchemyLoader
1+
from langchain_community.document_loaders.sql_database import SQLDatabaseLoader
22

33

4-
class CrateDBLoader(SQLAlchemyLoader):
4+
class CrateDBLoader(SQLDatabaseLoader):
55
pass

libs/community/langchain_community/document_loaders/sqlalchemy.py

Lines changed: 0 additions & 112 deletions
This file was deleted.

libs/community/tests/integration_tests/document_loaders/test_sql_database.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
warnings.warn("psycopg2 not installed, skipping corresponding tests", UserWarning)
4747
psycopg2_installed = False
4848

49+
try:
50+
import crate.client.sqlalchemy # noqa: F401
51+
52+
cratedb_installed = True
53+
except ImportError:
54+
warnings.warn("cratedb not installed, skipping corresponding tests", UserWarning)
55+
cratedb_installed = False
56+
4957

5058
@pytest.fixture()
5159
def engine(db_uri: str) -> sa.Engine:
@@ -74,6 +82,9 @@ def provision_database(engine: sa.Engine) -> None:
7482
continue
7583
connection.execute(sa.text(statement))
7684
connection.commit()
85+
if engine.dialect.name.startswith("crate"):
86+
connection.execute(sa.text("REFRESH TABLE mlb_teams_2012;"))
87+
connection.commit()
7788

7889

7990
tmpdir = TemporaryDirectory()
@@ -102,6 +113,18 @@ def pytest_generate_tests(metafunc: "Metafunc") -> None:
102113
"postgresql+psycopg2://langchain:langchain@localhost:6023/langchain"
103114
)
104115
ids.append("postgresql")
116+
if cratedb_installed:
117+
# We use non-standard port for testing purposes.
118+
# The easiest way to spin up the PostgreSQL instance is to use
119+
# the docker compose file at the root of the repo located at
120+
# langchain/docker/docker-compose.yml
121+
# use `docker compose up postgres` to start the instance
122+
# it will have the appropriate credentials set up including
123+
# being exposed on the appropriate port.
124+
urls.append(
125+
"crate://crate@localhost/?schema=testdrive"
126+
)
127+
ids.append("cratedb")
105128

106129
metafunc.parametrize("db_uri", urls, ids=ids)
107130

libs/community/tests/integration_tests/document_loaders/test_sqlalchemy_cratedb.py

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)