Function ic_sqlite_features::backup::db_backup_on_memory

source ·
pub fn db_backup_on_memory(conn: &mut Connection) -> Vec<u8> 
Expand description

Performs a backup of the database by loading it entirely into memory.

This function retrieves all pages of the database and accumulates them into a Vec<u8>. Be aware that this will try to bring the entire database into memory all at once, which may not be feasible for very large databases and could lead to high memory usage or out-of-memory errors.

§Returns

Returns a Vec<u8> containing the entire database’s raw data. The data is concatenated from each page of the database.

§Panics

This function may panic if:

  • The database connection is not properly initialized or locked.
  • The transaction cannot be started or committed.
  • Page data cannot be read from the virtual file system.

§Example

use ic_sqlite_features::backup::db_backup_on_memory;
let backup_data = db_backup_on_memory();
// Use `backup_data` as needed.