relay-knowledge 1.1.17

Graph-database-based knowledge graph project.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Reads bounded aggregate row counts for graph storage diagnostics.

use rusqlite::Connection;

use crate::storage::StorageError;

pub(super) fn count_rows(
    connection: &Connection,
    table: &'static str,
) -> Result<usize, StorageError> {
    let sql = format!("SELECT COUNT(*) FROM {table}");
    let count = connection.query_row(&sql, [], |row| row.get::<_, usize>(0))?;

    Ok(count)
}

#[cfg(test)]
mod mod_tests;