Skip to main content

get_stats

Function get_stats 

Source
pub async fn get_stats(db: &DB) -> Result<DbStats, Box<dyn Error + Send + Sync>>
Expand description

Retrieves statistics about the database, including table names, record counts, and sizes.

§Arguments

  • db - A reference to the database connection.

§Returns

  • Ok(DbStats) - A struct containing statistics about the database if the query is successful.
  • Err(Box<dyn Error + Send + Sync>) - An error if the query fails.

§Examples

let stats = get_stats(&db).await.unwrap();
println!("Total tables: {}", stats.tables.len());
for table in stats.tables {
    println!("Table: {}, Count: {}, Size: {} bytes", table.name, table.count, table.size_bytes);
}