tursodatabase/turso · error

Error in database list

Error message

Error in database list: {}

What it means

Wrapper thrown by database_names() when PRAGMA database_list fails while collecting the names of the main and attached databases (cli/app.rs:1716). The underlying error is chained, so the message shows the real cause - busy connection, unreadable file, or corrupt header.

Solutions

  1. Read the chained error text - it names the underlying LimboError
  2. Resolve the cause: reattach the missing database, restore read permission, or reopen the file
  3. Run PRAGMA database_list manually to reproduce
  4. Reopen the connection if it is in a bad state after an interrupt
Defensive patterns

Strategy: try-catch

Try / catch

let dbs = match app.database_names() {
    Ok(names) => names,
    Err(e) if e.to_string().contains("busy") => {
        std::thread::sleep(std::time::Duration::from_millis(100));
        app.database_names()?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling .databases or any completion path that uses database_names() while the connection is busy or interrupted, the main database file becomes unreadable, or an attached database vanishes or is corrupted mid-session.

Common situations: Attached files on removable or network storage that unmounted; permission changes while the shell is open; issuing .databases immediately after a Ctrl-C interrupt leaves statement state inconsistent.

Related errors


AI-assisted analysis of tursodatabase/turso@492c4a71cd (2026-08-20). Data as JSON: /api/errors/27e7a284c5167909. Report an issue: GitHub.

Appendix: source

Thrown at cli/app.rs:1726

            ));
        } else {
            let _ = self.writeln(b"No tables found in the database.");
        }
        Ok(())
    }

    fn database_names(&mut self) -> anyhow::Result<Vec<String>> {
        let sql = "PRAGMA database_list";
        let mut db_names: Vec<String> = Vec::new();
        let handler = |row: &turso_core::Row| {
            if let Ok(Value::Text(name)) = row.get::<&Value>(1) {
                db_names.push(name.to_string());
            }
            Ok(())
        };
        match self.handle_row(sql, handler) {
            Ok(_) => Ok(db_names),
            Err(e) => Err(anyhow::anyhow!("Error in database list: {}", e)),
        }
    }

    fn handle_row<F>(&mut self, sql: &str, handler: F) -> anyhow::Result<()>
    where
        F: FnMut(&turso_core::Row) -> turso_core::Result<()>,
    {
        match self.conn.query(sql) {
            Ok(Some(ref mut rows)) => {
                let res = rows.run_with_row_callback(handler);
                match res {
                    Ok(_) => {}
                    Err(LimboError::Busy) => {
                        let _ = self.writeln("database is busy");
                    }
                    Err(LimboError::Interrupt) => {
                        let _ = self.writeln(LimboError::Interrupt.to_string());
                    }

View on GitHub (pinned to 492c4a71cd)