Registry / database / sqlite-pusher

sqlite-pusher

JSON →
library0.3.0jsnpmunverified

Push sqlite entries for bi-directional synchronisation based on an incremental field in a sqlite table. Version 0.3.0 fetches the last sync state via GET, then pushes new records via PUT in configurable chunks at set intervals. Lightweight, Node.js-only, minimal dependencies: better-sqlite3 and node-fetch. Not actively maintained; last updated 2020. Suitable for simple uni-directional sync scenarios where polling and incremental IDs suffice.

npm install sqlite-pusher
INSTALL
IMPORT
SIG · SQLITE-PUSHER
S
sqlite-pusher
databasejavascriptv0.3.0
harness data pending
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.

pushSqlite
import { pushSqlite } from 'sqlite-pusher'
const pushSqlite = require('sqlite-pusher')
ESM-only since v0.3.0 (package.json type: module).
pushSqlite (default)
import pushSqlite from 'sqlite-pusher'
Default export equals named export pushSqlite; both work.
SQLPusher
import { SQLPusher } from 'sqlite-pusher'
import { SQLPusher } from 'sqlite-pusher' (wrong for default)
No SQLPusher export exists; use pushSqlite.

Initializes a background sync that periodically checks the SQLite table for new rows and pushes them to the configured push URL.

import { pushSqlite } from 'sqlite-pusher'; import Database from 'better-sqlite3'; const db = new Database('path/to/data.db'); const config = { database: '/absolute/path/to/data.db', table: 'items', urls: [{ lastUrl: process.env.LAST_URL ?? '', pushUrl: process.env.PUSH_URL ?? '' }], chunkSize: 5, incrCol: 'id', interval: 10000 }; pushSqlite(config).then(() => console.log('Sync started')).catch(err => console.error(err));
Debug
Known issues
breakingESM-only module – require() throws ERR_REQUIRE_ESM
fix
Use import syntax or dynamic import().
affects: >=0.3.0
gotchaMissing database file causes unhandled rejection on first call
fix
Ensure the SQLite database file exists before calling pushSqlite.
affects: >=0.3.0
gotchalastUrl must return a plain number (increment) or 404 – any other error breaks the loop
fix
Configure the server to return the last increment value as a number, or 404 on first sync.
affects: >=0.3.0
gotchapushUrl receives an array of rows wrapped in an object (e.g., {rows: [...]}) – may mismatch expected API
fix
Parse the request body on your server expecting {rows: [...]} or adjust client accordingly.
affects: >=0.3.0
gotchainterval polling does not stop automatically after catching up; runs indefinitely
fix
Implement logic to stop polling via the returned timer handle (not exposed currently).
affects: >=0.3.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sqlite-pusher' imported from ...
Missing dependencies (better-sqlite3, node-fetch) or not installed as dependencies
fix
npm install sqlite-pusher better-sqlite3 node-fetch
TypeError: db.prepare is not a function
Passed a database path string instead of a better-sqlite3 Database instance
fix
Create Database instance: const db = new Database('path'); then use db.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
better-sqlite3requiredSynchronous SQLite3 driver for Node.js
node-fetchrequiredHTTP client for GET/PUT requests
Agent activity
15 hits · last 30 days
node
12
Meta
2
OpenAI (training)
1
Resources
sqlite-pusher — npm install sqlite-pusher · libregistry