Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/sqlite/src/db.ts>DB#deserialize

Deno SQLite module
Go to Latest
method DB.prototype.deserialize
import { DB } from "https://deno.land/x/sqlite@v3.8/src/db.ts";

Deserialize a database.

The format is the same as would be read from disk when opening a database from a file.

When the database is deserialized, the contents of the passed data buffer are copied.

Examples

Replace the default (main) database schema with the contents from data.

db.deserialize(data);

Create an in-memory database from a buffer.

const db = new DB();
db.deserialize(data);

Deserialize data as a read-only database.

db.deserialize(data, { mode: "read" });

Specify a schema name different from main. Note that it is not possible to deserialize into the temp database.

db.execute("ATTACH DATABASE ':memory:' AS other"); // create schema 'other'
db.deserialize(data, { schema: "other" });

For more details see https://www.sqlite.org/c3ref/deserialize.html and https://www.sqlite.org/lang_attach.html.

Parameters

data: Uint8Array
optional
options: SqliteDeserializeOptions