{"record":{"id":"27e7a284c5167909","repo":"tursodatabase/turso","slug":"error-in-database-list","errorCode":null,"errorMessage":"Error in database list: {}","messagePattern":"Error in database list: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/app.rs","lineNumber":1703,"sourceCode":"            ));\n        } else {\n            let _ = self.writeln(b\"No tables found in the database.\");\n        }\n        Ok(())\n    }\n\n    fn database_names(&mut self) -> anyhow::Result<Vec<String>> {\n        let sql = \"PRAGMA database_list\";\n        let mut db_names: Vec<String> = Vec::new();\n        let handler = |row: &turso_core::Row| {\n            if let Ok(Value::Text(name)) = row.get::<&Value>(1) {\n                db_names.push(name.to_string());\n            }\n            Ok(())\n        };\n        match self.handle_row(sql, handler) {\n            Ok(_) => Ok(db_names),\n            Err(e) => Err(anyhow::anyhow!(\"Error in database list: {}\", e)),\n        }\n    }\n\n    fn handle_row<F>(&mut self, sql: &str, handler: F) -> anyhow::Result<()>\n    where\n        F: FnMut(&turso_core::Row) -> turso_core::Result<()>,\n    {\n        match self.conn.query(sql) {\n            Ok(Some(ref mut rows)) => {\n                let res = rows.run_with_row_callback(handler);\n                match res {\n                    Ok(_) => {}\n                    Err(LimboError::Busy) => {\n                        let _ = self.writeln(\"database is busy\");\n                    }\n                    Err(LimboError::Interrupt) => {\n                        let _ = self.writeln(LimboError::Interrupt.to_string());\n                    }","sourceCodeStart":1685,"sourceCodeEnd":1721,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/cli/app.rs#L1685-L1721","documentation":"database_names() (cli/app.rs:1692) runs PRAGMA database_list to enumerate attached databases; this power's '.tables'/'.indexes' iteration over schemas. Any failure of that pragma is wrapped as 'Error in database list: {e}' and aborts the dot command.","triggerScenarios":"PRAGMA database_list failing during a '.tables' or '.indexes' invocation: underlying I/O error (database file removed or unreadable mid-session), corrupted file header, or an internal connection error.","commonSituations":"The database file was deleted, moved, or its permissions changed while the CLI was still open; a file corrupted externally; flaky storage.","solutions":["Confirm the database file still exists and is readable (ls -l, cat attempt).","Restart the CLI and reopen the database — transient handle failures clear on reopen.","Run PRAGMA integrity_check; once open to check file health.","If using ATTACH'd databases, verify each path in '.databases' output still resolves."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"-- Cheap pre-flight before invoking dot commands that need the db list:\nPRAGMA database_list;  -- fails fast with the same underlying cause","typeGuard":null,"tryCatchPattern":"// Wrap '.tables'/.indexes' calls that depend on database_names and retry once\n// after reopening the connection:\nmatch shell.run(\".tables\") {\n    Err(e) if e.to_string().contains(\"Error in database list\") => {\n        shell.reopen()?;\n        shell.run(\".tables\")?;\n    }\n    other => other?,\n}","preventionTips":["Keep the underlying file present and readable for the whole CLI session.","Reopen the connection after any external process moves or rewrites the database file."],"tags":["cli","pragma","database-list","io"],"backgroundTag":"pragma-query-failed","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}