getredash/redash · error · Exception
Failed getting schema.
Error message
Failed getting schema.
What it means
Raised by Sqlite._get_tables (redash/query_runner/sqlite.py:40) when querying sqlite_master for the table list returns a non-None error. It fires while building the schema for the schema browser; the underlying run_query failure (unreadable/corrupt database file, locked database, permissions) is the actual cause but is discarded.
Source
Thrown at redash/query_runner/sqlite.py:40
}
@classmethod
def type(cls):
return "sqlite"
def __init__(self, configuration):
super(Sqlite, self).__init__(configuration)
self._dbpath = self.configuration.get("dbpath", "")
def _get_tables(self, schema):
query_table = "select tbl_name from sqlite_master where type='table'"
query_columns = 'PRAGMA table_info("%s")'
results, error = self.run_query(query_table, None)
if error is not None:
raise Exception("Failed getting schema.")
for row in results["rows"]:
table_name = row["tbl_name"]
schema[table_name] = {"name": table_name, "columns": []}
results_table, error = self.run_query(query_columns % (table_name,), None)
if error is not None:
self._handle_run_query_error(error)
for row_column in results_table["rows"]:
schema[table_name]["columns"].append(row_column["name"])
return list(schema.values())
def run_query(self, query, user):
connection = sqlite3.connect(self._dbpath)
cursor = connection.cursor()
View on GitHub (pinned to ca79fe988d)
Solutions
- Verify the database path is absolute and readable by the Redash worker user (test with `ls -l` and `sqlite3 <db> '.tables'` inside the worker container)
- If the file is locked, stop the writing process or enable WAL / busy_timeout on the writer
- If the file is corrupt or empty, restore from a backup or recreate it before refreshing the schema
Defensive patterns
Strategy: try-catch
Validate before calling
import os, sqlite3
if not os.path.isfile(db_path) or not os.access(db_path, os.R_OK):
raise ValueError('sqlite db missing/unreadable: {}'.format(db_path))
conn = sqlite3.connect(db_path); conn.close() Try / catch
try:
tables = ds.query_runner.get_schema()
except Exception as e:
logger.warning('sqlite schema failed: %s', e)
tables = [] Prevention
- Use absolute database paths visible to the worker container
- Enable WAL mode and set busy_timeout on writers to avoid lock failures
- Health-check the sqlite file (open/close) in the data source save handler
When it happens
Trigger: Opening the schema dialog for a SQLite data source whose file path is unreadable, is locked by another writer, or is not a valid SQLite database; also when the configured file lives on a path the Redash worker cannot access.
Common situations: Wrong file path in the data source config (relative vs absolute); database file on a mount not visible to the worker container; file created by a newer/incompatible SQLite page format or corrupt; concurrent writer holding an exclusive lock.
Related errors
- Error during query execution. Reason: {error}
- Failed to get schema: {str(e)}
- Failed to get tables: {error}
- Error creating table {}: {}
- Failed getting schema
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/54ee7f709f660e1b.
Report an issue: GitHub.