This `websql` package provides a Node.js implementation of the deprecated WebSQL Database API, leveraging `sqlite3` for its backend operations. It enables developers to run code originally designed for browser-based WebSQL environments within a Node.js context, and also falls back to `window.openDatabase` when used in a browser via bundlers like Browserify or Webpack. The current stable version is 2.0.3, with no explicit release cadence specified, indicating a focus on stability and compatibility rather than active feature development. Its primary differentiator is its strict adherence to the existing WebSQL API as implemented in browsers, acting as a bridge for legacy applications rather than extending the standard. It specifically *does not* aim to invent new APIs, support features like BLOBs or encryption, or enhance WebSQL beyond its original scope, focusing instead on accurate emulation for compatibility.
npm install websqlVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to open a WebSQL database, create a table, insert data, and query it using the `transaction` API.
For new projects, consider modern alternatives like IndexedDB or client-side SQLite libraries that are actively maintained.
Manage database schema versions and migrations separately in your application logic, or ensure your legacy code does not rely on WebSQL's internal versioning.
Do not expect modern SQLite features or extensions. If these are required, `websql` may not be suitable, and a direct `sqlite3` integration might be necessary.
Ensure target browser environments have WebSQL support if relying on browser fallback. For broader cross-browser compatibility, consider other storage solutions like IndexedDB.
Ensure the Node.js process has appropriate write permissions to the specified database directory. Use an absolute path or a path relative to the process's working directory, or use `:memory:` for an in-memory database.
Verify that `openDatabase` completed successfully and returned a valid database object. Check for any errors during the `openDatabase` call and ensure you're calling transaction methods on the correctly initialized `db` object.
Ensure `sqlite3` is installed as a direct dependency: `npm install sqlite3`. If it's a native module compilation issue, verify your environment meets `node-gyp` requirements (e.g., Python, C++ build tools).