Registry / database / mysql-sal

mysql-sal

JSON →
library0.0.6jsnpmunverified

A simple MySQL abstraction layer providing utility functions for common database operations. Current stable version is 0.0.6, with no recent releases and limited documentation. It wraps the mysql package to offer convenience methods like query, insert, update, and delete. Compared to alternatives like knex or sequelize, it is minimal and not actively maintained. Use with caution for production environments.

npm install mysql-sal
INSTALL
IMPORT
SIG · MYSQL-SAL
M
mysql-sal
databasejavascriptv0.0.6
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 export (the function/object)
import mysqlSal from 'mysql-sal';
const mysqlSal = require('mysql-sal');
ESM import is preferred; CommonJS require may work but not guaranteed for all environments.
config method
import mysqlSal from 'mysql-sal'; mysqlSal.config({ host: 'localhost', user: 'root', password: 'pass', database: 'test' });
const { config } = require('mysql-sal');
config is a method on the default export, not a named export.
query method
import mysqlSal from 'mysql-sal'; const result = await mysqlSal.query('SELECT * FROM users');
import { query } from 'mysql-sal';
query is a method on the default export, not a named export.

Configures connection, runs a simple query with parameterized input, and logs result.

import mysqlSal from 'mysql-sal'; // Configure connection mysqlSal.config({ host: 'localhost', user: 'root', password: process.env.DB_PASS ?? '', database: 'test' }); // Run a query async function main() { try { const rows = await mysqlSal.query('SELECT ?+? AS result', [1, 2]); console.log('Result:', rows); // Result: [ { result: 3 } ] } catch (err) { console.error('Error:', err); } } main();
Debug
Known issues
breakingNo named exports; default export only.
fix
Use default import: import mysqlSal from 'mysql-sal';
affects: >=0.0.1
gotchaPackage seems abandoned; no updates since initial release.
fix
Consider using a maintained alternative like mysql2 or knex.
affects: *
gotchaConfiguration must be called before any queries; missing config throws error.
fix
Always call mysqlSal.config() before any query/insert/update/delete.
affects: *
deprecatedThe underlying mysql package is no longer maintained; use mysql2 instead.
fix
Switch to mysql2 by replacing the mysql dependency with mysql2 and using mysql-sal with mysql2 (though compatibility not guaranteed).
affects: *
gotchaParameterized queries use question marks (?) unlike sprintf placeholders.
fix
Always use ? for parameters; do not manually escape inputs.
affects: *
Errors
Common errors & fixes
TypeError: mysqlSal.config is not a function
Using named import for config instead of default import.
fix
Use default import: import mysqlSal from 'mysql-sal'; then mysqlSal.config({...});
Error: Cannot find module 'mysql-sal'
Package not installed or not in node_modules.
fix
Run npm install mysql-sal (ensure it is in package.json dependencies).
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL server not running or connection configuration wrong.
fix
Start MySQL service or verify host/port credentials in config.
TypeError: Cannot read property 'query' of undefined
Missing configuration call before query.
fix
Call mysqlSal.config() first with valid connection details.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies
mysqlrequiredmysql package is a required peer dependency for database connectivity
Agent activity
4 hits · last 30 days
node
4
Resources
mysql-sal — npm install mysql-sal · libregistry