Skip to main content

import_plaintext_copy

Function import_plaintext_copy 

Source
pub fn import_plaintext_copy(
    conn: &Connection,
    source_path: &Path,
    tables: &[&str],
) -> DbResult<()>
Expand description

Imports data from a plaintext (unencrypted) database into an already-open encrypted database.

The source database is ATTACHed with an empty key and its contents are copied into the main (empty) encrypted database.

See export_plaintext_copy for why ATTACH + SQL is used instead of the sqlite3_backup API.

Schema migration: The import uses SELECT *, so column changes are handled automatically as long as both sides share the same schema. If a caller’s schema evolves (e.g. new columns with NOT NULL constraints), restoring an older backup into a newer schema will fail. When that happens, the caller needs version-aware import logic.

§Errors

Returns Error if the ATTACH, copy, or DETACH fails.