Registry /
database / meadow-connection-sqlite
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MeadowConnectionSQLite
✓ const MeadowConnectionSQLite = require('meadow-connection-sqlite');
✗ import MeadowConnectionSQLite from 'meadow-connection-sqlite';
CommonJS only - no ES module support. The package does not export a module field, so ESM imports will fail with ERR_REQUIRE_ESM or similar.
connectAsync
✓ connection.connectAsync((err, db) => {});
✗ connection.connectAsync().then(db => {});
connectAsync uses a callback, not Promises. There is no promise-based API.
db (getter)
✓ let stmt = connection.db.prepare('SELECT 1');
✗ let stmt = connection.db().prepare('SELECT 1');
db is a getter, not a method. Do not call it as a function.
Demonstrates in-memory SQLite database setup via Fable, Meadow schema DDL, and direct better-sqlite3 query execution
const libFable = require('fable');
const MeadowConnectionSQLite = require('meadow-connection-sqlite');
let fable = new libFable({
SQLite: {
SQLiteFilePath: ':memory:'
}
});
let connection = fable.instantiateServiceProvider(
'MeadowConnectionSQLite',
{},
MeadowConnectionSQLite
);
connection.connectAsync((pError, pDatabase) => {
if (pError) {
console.error('Connection failed:', pError);
return;
}
// Create a table and insert data
const schema = {
TableName: 'Users',
Columns: [
{ ColumnName: 'id', Type: 'ID' },
{ ColumnName: 'name', Type: 'String', Length: 100 },
{ ColumnName: 'createdAt', Type: 'DateTime' }
]
};
connection.createTable(schema, (err) => {
if (err) throw err;
const insert = connection.db.prepare('INSERT INTO Users (name) VALUES (?)');
insert.run('Alice');
console.log('User inserted');
});
});
Debug
Known issues
breakingRequires Node.js >= 22.5.0 due to better-sqlite3 native module compatibility. Older Node versions will cause installation or runtime failures.fixUpgrade Node.js to 22.5.0 or later.
affects: < 1.0.0 || all versions
gotchaThe package uses CommonJS (require) only. Importing with ES module syntax (import) will fail. There is no ESM entry point.fixUse require('meadow-connection-sqlite') and ensure your project uses CommonJS or wrap it in a dynamic import. affects: all
gotchaconnectAsync uses a callback pattern, not Promises. Attempting to await it will hang indefinitely.fixUse the callback parameter: connection.connectAsync((err, db) => { ... }). affects: all
deprecatedThe synchronous connect() method logs a warning and should not be used in production. It may be removed in future versions.fixUse connectAsync instead.
affects: >= 1.0.0
gotchaThe db getter returns the underlying better-sqlite3 database object directly. Modifying it (e.g., closing it) may break the Meadow connection state.fixAvoid calling db.close() manually. Use meadow-connection-sqlite methods for cleanup.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'meadow-connection-sqlite'
Package not installed or wrong import syntax in ESM context.
fixInstall the package: npm install meadow-connection-sqlite. Ensure you use require(), not import.
TypeError: connection.db is not a function
Attempting to call db() as a method instead of accessing it as a property.
fixUse connection.db (without parentheses) to access the better-sqlite3 database instance.
Error: The specified module could not be found. \\?\\...\\better_sqlite3.node
better-sqlite3 native addon failed to compile or load, often due to Node version mismatch or missing build tools.
fixEnsure Node >= 22.5.0 and rebuild native modules: npm rebuild better-sqlite3. On Windows, install windows-build-tools.
Error: SQLITE_ERROR: no such table: Users
Table not created before querying it.
fixCall connection.createTable() with the appropriate Meadow schema before running SELECT/INSERT queries.
Audit
Dependencies
better-sqlite3requiredPeer dependency for underlying SQLite access; meadow-connection-sqlite wraps and re-exports better-sqlite3 functionality
fablerequiredRequired as the service provider framework; meadow-connection-sqlite registers as a Fable service