-
Checked other resources
Commit to Help
Example Codefrom langchain_community.utilities import SQLDatabase
parquet = "https://data.source.coop/cboettig/pad-us-3/pad-mobi.parquet"
q = f"CREATE OR REPLACE VIEW pad AS SELECT * FROM read_parquet('{parquet}')"
db = SQLDatabase.from_uri("duckdb:///:memory:")
db.run(q)
db.get_usable_table_names() # nothing But duckdb works fine: import duckdb
duckdb.sql(q)
duckdb.sql("show tables;") DescriptionI'm trying to follow the SQL agent quickstart documentation to use a duckdb connection. langchain appears to initialize my db without error using The same query run with System Info
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The discrepancy you're experiencing with LangChain and DuckDB, particularly with the LangChain's DuckDB and SQLAlchemy have different approaches to handling in-memory databases, particularly in setting the search path or schema. This difference could lead to discrepancies in table recognition. Specifically, the To address this issue, ensuring the correct setting of the search path when using LangChain's This explanation aims to clarify the potential cause of the issue you're facing. If further questions arise or additional clarification is needed, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Langchain should fix this issue as the usage of DuckDB is increasing |
Beta Was this translation helpful? Give feedback.
The issue you're encountering with
get_usable_table_names()
not recognizing views and in-memory tables in LangChain'sSQLDatabase
class seems to stem from the handling of theview_support
parameter. By default, this parameter is set toFalse
, which means views, and potentially in-memory tables, are not included in the list of tables returned byget_usable_table_names()
.To address this, you should instantiate the
SQLDatabase
object withview_support=True
. This adjustment enables the class to recognize views and in-memory tables. Here's how you can do it: