get_table_row_count

Function get_table_row_count 

Source
pub async fn get_table_row_count(
    conn: &mut Conn,
    db_name: &str,
    table_name: &str,
) -> Result<usize>
Expand description

Get row count for a MySQL table

Executes COUNT(*) query to determine table size.

§Arguments

  • conn - MySQL connection
  • db_name - Database name
  • table_name - Table name

§Returns

Number of rows in the table

§Examples

let mut conn = connect_mysql("mysql://localhost:3306/mydb").await?;
let count = get_table_row_count(&mut conn, "mydb", "users").await?;
println!("Table has {} rows", count);