import_database_from_bytes

Function import_database_from_bytes 

Source
pub async fn import_database_from_bytes(
    db_name: &str,
    data: Vec<u8>,
) -> Result<(), DatabaseError>
Expand description

Import SQLite database from bytes into BlockStorage

Takes a complete SQLite .db file and imports it into the block-based storage system. This is the inverse of export_database_to_bytes().

§Arguments

  • db_name - Name of the database to import into
  • data - Complete SQLite database file as bytes

§Returns

  • Ok(()) - Import successful
  • Err(DatabaseError) - If validation or import fails

§Process

  1. Validate SQLite file format
  2. Clear existing storage for the database
  3. Split data into BLOCK_SIZE (4096-byte) chunks
  4. Pad last block with zeros if needed
  5. Write all blocks to GLOBAL_STORAGE
  6. Update allocation map

§Example

use absurder_sql::storage::import::import_database_from_bytes;

let db_bytes = std::fs::read("mydb.db").unwrap();
import_database_from_bytes("mydb", db_bytes).await?;