websql-configurable is a JavaScript/TypeScript library (version 3.0.3) that implements the WebSQL Database API for Node.js environments, leveraging `node-sqlite3` as its backend. It is a fork of `node-websql` which provides additional configuration options and incorporates TypeScript types from `@types/websql`. This package allows developers to reuse legacy WebSQL-based code in Node.js, facilitating quick testing and bridging existing WebSQL implementations to a Node.js context. When used in a browser environment via bundlers like Browserify or Webpack, it gracefully falls back to the native `window.openDatabase` implementation, subject to current browser support. The library aims for strict compatibility with the existing WebSQL API as found in browsers, focusing on bridging the gap rather than expanding the deprecated standard. Its release cadence is primarily driven by maintenance needs and fixes for its specific niche. A key differentiator is its enhanced configurability for the underlying `sqlite3` driver and the ability to swap custom SQLite3 implementations.
npm install websql-configurableVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to open a file-based or in-memory WebSQL database in Node.js, create a table, insert data, and query it within a transaction using the `websql-configurable` API.
For new projects, consider modern alternatives like IndexedDB (for browsers) or standalone SQLite/PostgreSQL/MySQL libraries (for Node.js).
Do not rely on `version` for schema management. Implement schema updates manually as part of your application logic.
Adhere strictly to the WebSQL API standard SQL subset. If advanced SQLite features are needed, consider using `node-sqlite3` directly or another dedicated database driver.
Thoroughly test browser compatibility if targeting the browser. For robust browser storage, consider IndexedDB or local storage solutions.
Always use `results.rows.item(i)` to access individual rows within a `SQLResultSetRowList` to guarantee consistent behavior across environments.
Ensure you are using `import openDatabase from 'websql-configurable';` for ESM/TypeScript projects. If using CommonJS, `const openDatabase = require('websql-configurable');` is correct.Restrict SQL statements to the WebSQL standard. For binary data, consider storing it as `TEXT` (Base64 encoded) or as `INTEGER` (if referencing an external binary store).
Implement database schema migration logic manually within your application. The `version` parameter is ignored by this library for functional purposes.
Ensure your target browser environment supports `window.openDatabase` (primarily Chrome, or older versions of other browsers). For broader browser compatibility, consider switching to IndexedDB or other web storage APIs for new development.