{"id":16797,"library":"database-js-sqlite","title":"Database-js SQLite Driver","description":"database-js-sqlite serves as a wrapper for the `node-sqlite3` package, providing SQLite database connectivity for applications utilizing the `database-js` framework. It enables a consistent API for interacting with SQLite databases, including support for prepared statements and async/await operations. Additionally, it offers an alternative driver option for `sql.js` for browser-compatible SQLite usage. The current stable version is 1.3.0, released in 2018. Given the lack of recent updates, the package appears to be in a maintenance or effectively abandoned state, meaning release cadence is irregular or ceased, and compatibility with very recent Node.js versions or security patches might be a concern. Its primary differentiator is its integration within the `database-js` ecosystem, providing a unified interface across different database types.","status":"maintenance","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/mlaanderson/database-js-sqlite","tags":["javascript","database-js","sqlite"],"install":[{"cmd":"npm install database-js-sqlite","lang":"bash","label":"npm"},{"cmd":"yarn add database-js-sqlite","lang":"bash","label":"yarn"},{"cmd":"pnpm add database-js-sqlite","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core framework required for connection abstraction.","package":"database-js","optional":false},{"reason":"Primary underlying SQLite driver for Node.js environments.","package":"node-sqlite3","optional":false},{"reason":"Alternative SQLite driver for browser environments or where native modules are undesired. Used when 'driver=sql.js' is specified.","package":"sql.js","optional":true}],"imports":[{"note":"While the README historically showed `database-js2`, the correct package name for the core framework is `database-js`. This is the main class used to establish database connections after `database-js-sqlite` is installed and registers its driver.","wrong":"var Database = require('database-js2').Connection;","symbol":"Connection","correct":"import { Connection } from 'database-js';"},{"note":"This package exports its `SQLiteConnection` as a default export, though typical usage with `database-js` involves letting `database-js` auto-discover the driver via the connection string rather than direct instantiation.","wrong":"import { SQLiteConnection } from 'database-js-sqlite';","symbol":"SQLiteConnection","correct":"import SQLiteConnection from 'database-js-sqlite';"},{"note":"For CommonJS environments, `Connection` is destructured from `database-js`. While `database-js-sqlite` exports `SQLiteConnection` as a default, the quickstart's `new Database(...)` refers to the core `Connection` object.","wrong":"const Database = require('database-js-sqlite');","symbol":"Database (CJS)","correct":"const { Connection: Database } = require('database-js');"}],"quickstart":{"code":"import { Connection } from 'database-js';\n\n// Ensure database-js-sqlite and node-sqlite3 are installed:\n// npm install database-js database-js-sqlite node-sqlite3\n\n(async () => {\n    let connection;\n    try {\n        // Connect to an SQLite database file. It will be created if it doesn't exist.\n        connection = new Connection('sqlite:///test.sqlite');\n        console.log('Database connection established.');\n\n        // Create a table if it doesn't exist\n        await connection.query(\n            \"CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, user_name TEXT, email TEXT);\"\n        );\n        console.log('Table 'users' ensured.');\n\n        // Insert data using a prepared statement\n        let statement = await connection.prepareStatement(\"INSERT INTO users (user_name, email) VALUES (?, ?)\");\n        await statement.query('john_doe', 'john@example.com');\n        await statement.query('jane_smith', 'jane@example.com');\n        console.log('Users inserted.');\n\n        // Query data using a prepared statement\n        statement = await connection.prepareStatement(\"SELECT * FROM users WHERE user_name = ?\");\n        const rows = await statement.query('john_doe');\n        console.log('Query result for john_doe:', rows);\n\n    } catch (error) {\n        console.error('Database operation failed:', error);\n    } finally {\n        if (connection) {\n            await connection.close();\n            console.log('Database connection closed.');\n        }\n    }\n})();","lang":"javascript","description":"Demonstrates connecting to an SQLite database, creating a table, inserting data, and querying using prepared statements with the `database-js` API."},"warnings":[{"fix":"Always use `require('database-js')` or `import { Connection } from 'database-js'` for the core library.","message":"The README and examples historically referenced `database-js2`. The correct package name for the core library is `database-js`. Using `database-js2` will result in a 'Cannot find module' error.","severity":"gotcha","affected_versions":"<=1.3.0"},{"fix":"Thoroughly test compatibility with your target Node.js version. Consider alternative, more actively maintained SQLite drivers if encountering issues with newer environments.","message":"This package, and its core dependency `database-js`, have not seen significant updates since 2018-2019. This means it may not be compatible with newer Node.js versions (e.g., > v16) or may lack support for modern JavaScript features or API changes.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure you have Python 2.x/3.x, `make` (Linux/macOS) or Visual Studio Build Tools (Windows) installed. Refer to `node-sqlite3` documentation for troubleshooting native module compilation errors. Consider using the `sql.js` driver option for purely JavaScript environments.","message":"The underlying `node-sqlite3` package is a native module, which can cause installation issues (e.g., `node-gyp` errors) if build tools are not properly configured on your system or if prebuilt binaries are unavailable for your specific OS/Node.js architecture.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install `sql.js` (e.g., `npm install sql.js`) if you intend to use it as the SQLite driver: `connection = new Connection('sqlite:///test.sqlite?driver=sql.js');`","message":"When specifying the `sql.js` driver, ensure `sql.js` is installed as a dependency. Without it, the connection attempt will fail when `driver=sql.js` is used.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.3.0':70 '2018':73 'abandon':90 'across':129 'addit':50 'altern':54 'api':36 'appear':82 'applic':25 'async/await':48 'browser':61 'browser-compat':60 'cadenc':94 'ceas':98 'compat':62,100 'concern':112 'connect':23 'consist':35 'current':66 'databas':2,7,22,29,41,122,131,135 'database-j':1,28,121,134 'database-js-sqlit':6 'differ':130 'differenti':115 'driver':5,55 'ecosystem':124 'effect':89 'enabl':33 'framework':31 'given':74 'includ':42 'integr':118 'interact':38 'interfac':128 'irregular':96 'javascript':133 'js':3,8,30,123,136 'lack':76 'mainten':87 'mean':92 'might':109 'node':17 'node-sqlite3':16 'node.js':104 'offer':52 'oper':49 'option':56 'packag':19,81 'patch':108 'prepar':45 'primari':114 'provid':20,125 'recent':78,103 'releas':71,93 'secur':107 'serv':10 'sql.js':58 'sqlite':4,9,21,40,63,137 'sqlite3':18 'stabl':67 'state':91 'statement':46 'support':43 'type':132 'unifi':127 'updat':79 'usag':64 'util':26 'version':68,105 'within':119 'wrapper':13","created_at":"2026-04-22T14:24:30.112671+00:00","updated_at":"2026-04-22T14:24:30.112671+00:00","problems":[{"fix":"Change your import statement from `require('database-js2')` to `require('database-js')` or `import { Connection } from 'database-js';`.","cause":"The core `database-js` library was incorrectly referred to as `database-js2` in older documentation or examples.","error":"Error: Cannot find module 'database-js2'"},{"fix":"Delete `node_modules` and `package-lock.json`, then reinstall: `rm -rf node_modules package-lock.json && npm install`. If issues persist, ensure `node-gyp` is configured correctly or try rebuilding `node-sqlite3` specifically using `npm rebuild node-sqlite3`.","cause":"The native `node-sqlite3` module was compiled against a different Node.js N-API version than the one currently running, often due to Node.js version changes or corrupted `node_modules`.","error":"Error: NAPI_VERSION_MISMATCH (node-sqlite3)"},{"fix":"Ensure `database-js-sqlite` is listed in your dependencies and properly installed: `npm install database-js-sqlite`.","cause":"The `database-js-sqlite` package, which registers the 'sqlite' driver for `database-js`, is not installed or accessible in your project.","error":"Error: A database-js driver for 'sqlite' could not be found."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mlaanderson/database-js-sqlite","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/database-js-sqlite","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-21","install_tag":null}}