[API reference](https://evolu.dev/docs/api-reference) › [@evolu/sqlite-wasm](https://evolu.dev/docs/api-reference/sqlite-wasm) › [c-api](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api) › sqlite3\_serialize

```ts
function sqlite3_serialize(deps: SqliteWasmDep): {
  (
    db: SqliteDbPtr,
    zSchema: 0 | CStringPtr,
    piSize: 0 | WasmPtr,
    mFlags: 0,
  ): 0 | SqliteOwnedPtr;
  (
    db: SqliteDbPtr,
    zSchema: 0 | CStringPtr,
    piSize: 0 | WasmPtr,
    mFlags: number,
  ): 0 | WasmPtr;
};
```

Defined in: [packages/sqlite-wasm/src/CApi.ts:1531](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/sqlite-wasm/src/CApi.ts#L1531)

Copies a schema, NULL meaning main, into memory from [sqlite3\_malloc64](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api/functions/sqlite3_malloc64)
that the caller frees, writing its byte size as an 8-byte sqlite3_int64 to
piSize unless NULL. An empty database first gets its first page from an empty
write transaction. Pages are read through the pager, so an encrypted database
comes out decrypted, and a page that fails to read comes out zero-filled.
Returns NULL when out of memory, for an unknown schema or a database without
pages, and with SQLITE_SERIALIZE_NOCOPY returns SQLite's own buffer of a
deserialized database, or NULL, instead of a copy, which the caller must
neither free nor modify. Only a call whose mFlags is 0 returns memory
[sqlite3\_free](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api/functions/sqlite3_free) accepts.

Wasm type `i(iiii)`. Signature `["sqlite3_serialize", "*", "sqlite3*",
"string", "*", "int"]` from SQLite's table.

See https://sqlite.org/c3ref/serialize.html.