
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@magieno/sqlite-client
Advanced tools
SQLite Client is a wrapper for Sqlite on Wasm that uses the Origin Private File System to persist the sqlite database file.
SQLite Client is a wrapper for SQLite that uses the Origin Private File System (OPFS) to persist the SQLite database file.
It only supports OPFS as a persistence mechanism.
This library has two important files: sqlite-client.js
and sqlite-client-worker.js
.
Due to some browser restrictions, SQLite WASM can only persist over OPFS when executed in a Worker.
Behind the scenes, Sqlite communicates with a worker to run the SQL statements and return you the results
on the main thread.
1- Install the NPM package
npm install @magieno/sqlite-client
2- Import the sqlite-client
library in your code and use it as such:
import {SqliteClient} from "@magieno/sqlite-client";
const sqliteWorkerPath = "assets/js/sqlite-client-worker.js"; // Must correspond to the path in your final deployed build.
const filename = "/test.sqlite3"; // This is the name of your database. It corresponds to the path in the OPFS.
const sqliteClient = new SqliteClient({
filename,
sqliteWorkerPath,
})
await sqliteClient.init();
await sqliteClient.executeSql("CREATE TABLE IF NOT EXISTS test(a,b)");
await sqliteClient.executeSql("INSERT INTO test VALUES(?, ?)", [6,7]);
const results = await sqliteClient.executeSql("SELECT * FROM test");
3- Copy the node_modules/@magieno/sqlite-client/dist/bundle/sqlite-client-worker.js
to your final bundle
This is dependent on the framework you are using but the idea is that this .js file should be copied and available in your build.
4- Copy the files node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/*
file to your final bundle next to sqlite-client-worker.js
.
5- Warning Your server must set the following Http headers when serving your files
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
We have created a repository that contains demos that you can look at:
FAQs
SQLite Client is a wrapper for Sqlite on Wasm that uses the Origin Private File System to persist the sqlite database file.
We found that @magieno/sqlite-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.