run-llama/llama_index · error · ValueError
ignore_tables {missing_tables} not found in database
Error message
ignore_tables {missing_tables} not found in database What it means
Mirror of the include_tables check: every name in ignore_tables must exist in the introspected schema (tables, plus views only when view_support=True). Unknown names in the blocklist raise ValueError naming the missing tables, because silently ignoring them would hide configuration mistakes.
Source
Thrown at llama-index-core/llama_index/core/utilities/sql_wrapper.py:82
# including view support by adding the views as well as tables to the all
# tables list if view_support is True
self._all_tables = set(
self._inspector.get_table_names(schema=schema)
+ (self._inspector.get_view_names(schema=schema) if view_support else [])
)
self._include_tables = set(include_tables) if include_tables else set()
if self._include_tables:
missing_tables = self._include_tables - self._all_tables
if missing_tables:
raise ValueError(
f"include_tables {missing_tables} not found in database"
)
self._ignore_tables = set(ignore_tables) if ignore_tables else set()
if self._ignore_tables:
missing_tables = self._ignore_tables - self._all_tables
if missing_tables:
raise ValueError(
f"ignore_tables {missing_tables} not found in database"
)
usable_tables = self.get_usable_table_names()
self._usable_tables = set(usable_tables) if usable_tables else self._all_tables
if not isinstance(sample_rows_in_table_info, int):
raise TypeError("sample_rows_in_table_info must be an integer")
self._sample_rows_in_table_info = sample_rows_in_table_info
self._indexes_in_table_info = indexes_in_table_info
self._custom_table_info = custom_table_info
if self._custom_table_info:
if not isinstance(self._custom_table_info, dict):
raise TypeError(
"table_info must be a dictionary with table names as keys and the "
"desired table info as values"
)View on GitHub (pinned to afd0fef371)
Solutions
- Refresh the blocklist against the live schema: set(insp.get_table_names()) & set(ignore_tables).
- Drop names that no longer exist, or regenerate the list from the current database.
- Enable view_support=True if the ignored relation is a view.
Example fix
# before
db = SQLDatabase(engine, ignore_tables=['legacy_logs']) # table dropped -> ValueError
# after
from sqlalchemy import inspect
valid = set(inspect(engine).get_table_names())
db = SQLDatabase(engine, ignore_tables=list(valid & {'legacy_logs', 'tmp'})) Defensive patterns
Strategy: validation
Validate before calling
from sqlalchemy import inspect
def filter_ignore_tables(engine, ignore_tables, schema=None, view_support=False):
insp = inspect(engine)
existing = set(insp.get_table_names(schema=schema))
if view_support:
existing |= set(insp.get_view_names(schema=schema))
return list(existing & set(ignore_tables or [])) # drop stale names safely Type guard
def ignore_tables_exist(engine, ignore_tables, schema=None) -> bool:
existing = set(inspect(engine).get_table_names(schema=schema))
return set(ignore_tables) <= existing Try / catch
try:
db = SQLDatabase(engine, ignore_tables=tables)
except ValueError as e:
if 'ignore_tables' in str(e) and 'not found' in str(e):
existing = set(inspect(engine).get_table_names())
db = SQLDatabase(engine, ignore_tables=list(existing & set(tables)))
else:
raise Prevention
- Intersect blocklists with live table names at startup to drop stale entries.
- Regenerate ignore lists after migrations rename or drop tables.
- Enable view_support=True when blocklisting views.
When it happens
Trigger: SQLDatabase(engine, ignore_tables=['old_audit']) after the table was dropped; ignoring a view without view_support=True; schema-qualified or case-mismatched names that never match introspected names.
Common situations: Long-lived apps whose blocklist references tables removed by migrations; porting configs between dev/prod databases with different tables; copying ignore lists written for a different schema.
Related errors
- include_tables {missing_tables} not found in database
- Invalid context table names: {context_keys - set(self.sql_da
- Cannot specify both include_tables and ignore_tables
- Statement {command!r} is invalid SQL.\nError: {exc.orig}
- sql_database must be provided.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/0419f2dcd30b04ac.
Report an issue: GitHub.