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 intodata- Complete SQLite database file as bytes
§Returns
Ok(())- Import successfulErr(DatabaseError)- If validation or import fails
§Process
- Validate SQLite file format
- Clear existing storage for the database
- Split data into BLOCK_SIZE (4096-byte) chunks
- Pad last block with zeros if needed
- Write all blocks to GLOBAL_STORAGE
- 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?;