{"record":{"id":"f2a09c7d9c361959","repo":"tursodatabase/turso","slug":"unable-to-access-database-schema-the-database-may","errorCode":null,"errorMessage":"Unable to access database schema. The database may be using an older SQLite version or may not be properly initialized.","messagePattern":"Unable to access database schema\\. The database may be using an older SQLite version or may not be properly initialized\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/app.rs","lineNumber":1636,"sourceCode":"                Some(ref tbl_name) => format!(\n                    \"SELECT name FROM {name}.sqlite_schema WHERE type='index' AND tbl_name = '{tbl_name}' ORDER BY 1\"\n                ),\n                None => format!(\"SELECT name FROM {name}.sqlite_schema WHERE type='index' ORDER BY 1\"),\n            };\n            let handler = |row: &turso_core::Row| {\n                if let Ok(Value::Text(idx)) = row.get::<&Value>(0) {\n                    if let Some(prefix) = prefix {\n                        indexes.push_str(prefix);\n                        indexes.push('.');\n                    }\n                    indexes.push_str(idx.as_str());\n                    indexes.push(' ');\n                }\n                Ok(())\n            };\n            if let Err(err) = self.handle_row(&sql, handler) {\n                if err.to_string().contains(\"no such table: sqlite_schema\") {\n                    return Err(anyhow::anyhow!(\"Unable to access database schema. The database may be using an older SQLite version or may not be properly initialized.\"));\n                } else {\n                    return Err(anyhow::anyhow!(\"Error querying schema: {}\", err));\n                }\n            }\n        }\n        if !indexes.is_empty() {\n            let _ = self.writeln(indexes.trim_end().as_bytes());\n        }\n        Ok(())\n    }\n\n    fn display_tables(&mut self, pattern: Option<&str>) -> anyhow::Result<()> {\n        let mut tables = String::new();\n\n        for name in self.database_names()? {\n            let prefix = (name != \"main\").then_some(&name);\n            let sql = match pattern {\n                Some(pattern) => format!(","sourceCodeStart":1618,"sourceCodeEnd":1654,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/cli/app.rs#L1618-L1654","documentation":"While executing '.indexes', the CLI selects index names from sqlite_schema. When the engine reports 'no such table: sqlite_schema', the CLI maps it to this message: the database's schema catalog itself is unreadable, which happens with pre-3.3.0 SQLite files (which only expose sqlite_master) or with a file that is not a properly initialized SQLite database.","triggerScenarios":"Running '.indexes' on a very old SQLite database file, on a file that is not a SQLite database at all (random bytes, wrong format), or in an engine state where the schema table cannot be resolved.","commonSituations":"Pointing the CLI at a legacy export or an unrelated binary file; a zero-length or header-only file created by a failed open; version-skew where an old tool wrote a sqlite_master-only catalog.","solutions":["Verify the file is a SQLite database: check for the 16-byte header 'SQLite format 3\\0' (e.g. 'file mydb' or 'head -c 16 mydb').","Try the legacy catalog name: SELECT name FROM sqlite_master; — older databases only have that table.","Modernize the file: open it with the sqlite3 shell and pipe '.dump' into a fresh database, then use the new file.","Reopen the database from a fresh CLI session to rule out a transient open failure."],"exampleFix":"-- before\n.indexes\n-- Error: Unable to access database schema. ...\n\n-- after: rebuild the catalog in a modern file\n-- (in sqlite3 shell) .open legacy.db  |  .dump | sqlite3 new.db\n-- then: tursodb new.db -c '.indexes'","handlingStrategy":"validation","validationCode":"-- Probe the catalog before running .indexes:\nSELECT 1 FROM sqlite_schema LIMIT 1;      -- modern name\nSELECT 1 FROM sqlite_master LIMIT 1;      -- legacy fallback","typeGuard":null,"tryCatchPattern":"// On the 'Unable to access database schema' error, retry the query against\n// the legacy catalog before giving up:\nif err.to_string().contains(\"Unable to access database schema\") {\n    let names = query_legacy_sqlite_master()?;\n}","preventionTips":["Check the file header ('SQLite format 3\\0') before opening untrusted/legacy files.","Modernize legacy databases once (dump + re-import) instead of handling both catalog names forever."],"tags":["cli","schema","indexes","sqlite-schema","legacy-format"],"backgroundTag":"missing-system-table","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}