mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
fix sqlite internal tables breaking table_info (#1224)
With the current method used to get the SQL table info, sqlite internal schema tables are being included and are not being handled correctly by sqlalchemy because the columns have no types. This is easy to see with the Chinook database: ```python db = SQLDatabase.from_uri("sqlite:///Chinook.db") print(db.table_info) ``` ```python ... sqlalchemy.exc.CompileError: (in table 'sqlite_sequence', column 'name'): Can't generate DDL for NullType(); did you forget to specify a type on this Column? ``` SQLAlchemy 2.0 [ignores these by default](63d90b0f44/lib/sqlalchemy/dialects/sqlite/base.py (L856-L880)
):63d90b0f44/lib/sqlalchemy/dialects/sqlite/base.py (L2096-L2123)
This commit is contained in:
parent
4e28982d2b
commit
ac1320aae8
@ -94,6 +94,7 @@ class SQLDatabase:
|
||||
tbl
|
||||
for tbl in self._metadata.sorted_tables
|
||||
if tbl.name in set(all_table_names)
|
||||
and not (self.dialect == "sqlite" and tbl.name.startswith("sqlite_"))
|
||||
]
|
||||
|
||||
tables = []
|
||||
|
Loading…
Reference in New Issue
Block a user