Registry / database / sqllog

sqllog

JSON →
library0.4.2jsnpmunverified

sqlLog (v0.4.2) is a lightweight library that adds a simple logging table to an SQL database, built on top of the davesql package. It provides automatic creation of a 'log' table with fields for event name, error, JSON data, and timestamp. Designed for quick integration, it offers methods to append events and retrieve recent operations. Release cadence is low; last update 2016. Differentiator: minimal setup, ideal for small apps needing basic SQL logging without a full ORM.

npm install sqllog
INSTALL
IMPORT
SIG · SQLLOG
S
sqllog
databasejavascriptv0.4.2
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.

default
✓ import sqlLog from 'sqllog'
✗ const sqlLog = require('sqllog')
ESM-only; no CommonJS support.
append
✓ import { append } from 'sqllog'
Named export for appending events.
recent
✓ import { recent } from 'sqllog'
✗ import sqlLog from 'sqllog'; sqlLog.recent
recent is a named function, not a method of default export.

Initialize davesql, connect to MySQL, then use sqlLog to log events and retrieve recent entries.

import davesql from 'davesql'; import sqlLog from 'sqllog'; // create a davesql instance const db = new davesql.DaveSql(); const config = { host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test' }; db.connect(config); // initialize sqlLog sqlLog.init(db); // append a log entry sqlLog.append('user_login', { user: 'alice' }); // get recent events const recent = sqlLog.recent(10); console.log(recent);
Debug
Known issues
breakingdavesql package must be initialized before using sqlLog; sqlLog.init(db) will fail if db is not a valid davesql instance.
fix
Ensure davesql is properly installed and connected before calling sqlLog.init().
affects: >=0.0
gotchaThe log table is automatically created by sqlLog.init() if it doesn't exist; but if the table already has a different schema, init() may fail or cause errors.
fix
Manually create the log table with the expected schema before using sqlLog, or drop the existing table and let sqlLog recreate it.
affects: >=0.0
deprecatedCurrent version (0.4.2) is old and may not be actively maintained; there are potential security fixes in newer versions of davesql that may not be reflected.
fix
Consider evaluating if the package is still suitable for production use; check for alternative logging libraries.
affects: <=0.4.2
gotchaThe append function expects eventData as an object; passing a string may lead to unexpected behavior.
fix
Always pass an object for eventData, e.g., { message: 'some string' }.
affects: >=0.0
Errors
Common errors & fixes
TypeError: sqlLog.init is not a function
Importing the default export incorrectly; sqlLog.default may be needed.
fix
Use import sqlLog from 'sqllog' and then call sqlLog.init().
Cannot find module 'davesql'
davesql is not installed.
fix
Run 'npm install davesql' in your project.
ER_BAD_DB_ERROR: Unknown database 'test'
The specified database does not exist.
fix
Create the database first: CREATE DATABASE test;
Table 'log' already exists
sqlLog.init() tries to create the log table but it already exists with possibly different schema.
fix
Drop the existing log table or ensure it matches the expected schema.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
davesqlrequiredCore dependency for SQL operations; sqlLog extends davesql.
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
packagesqllog ↗
sqllog — npm install sqllog · libregistry