tursodatabase/turso · error

Error in database list: {}

Error message

Error in database list: {}

What it means

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.

Source

Thrown at cli/app.rs:1703

            ));
        } 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 bad083fafb)

Solutions

  1. Confirm the database file still exists and is readable (ls -l, cat attempt).
  2. Restart the CLI and reopen the database — transient handle failures clear on reopen.
  3. Run PRAGMA integrity_check; once open to check file health.
  4. If using ATTACH'd databases, verify each path in '.databases' output still resolves.
Defensive patterns

Strategy: try-catch

Validate before calling

-- Cheap pre-flight before invoking dot commands that need the db list:
PRAGMA database_list;  -- fails fast with the same underlying cause

Try / catch

// Wrap '.tables'/.indexes' calls that depend on database_names and retry once
// after reopening the connection:
match shell.run(".tables") {
    Err(e) if e.to_string().contains("Error in database list") => {
        shell.reopen()?;
        shell.run(".tables")?;
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: The database file was deleted, moved, or its permissions changed while the CLI was still open; a file corrupted externally; flaky storage.

Related errors


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