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 Mysql from 'node-mysql-promise'
✗ const { Mysql } = require('node-mysql-promise')
CommonJS require returns the constructor directly, not an object.
createConnection
✓ import Mysql from 'node-mysql-promise'; const mysql = Mysql.createConnection({...})
✗ const mysql = require('node-mysql-promise').createConnection({...})
createConnection is a static method on the default export.
table
✓ import Mysql from 'node-mysql-promise'; const mysql = Mysql.createConnection({...}); mysql.table('table').select()
✗ const mysql = require('node-mysql-promise')({...}); mysql.select()
table() must be called before query methods like select().
Shows basic SELECT, INSERT, UPDATE, DELETE operations using node-mysql-promise.
const Mysql = require('node-mysql-promise');
const mysql = Mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'test'
});
mysql.table('users').select()
.then(rows => console.log(rows))
.catch(err => console.error(err));
// Insert example
mysql.table('users').add({ name: 'John', age: 30 })
.then(result => console.log('Insert id:', result))
.catch(err => console.error(err));
// Update example
mysql.table('users').where({ id: 1 }).update({ name: 'Jane' })
.then(affectedRows => console.log('Updated', affectedRows, 'rows'))
.catch(err => console.error(err));
// Delete example
mysql.table('users').where({ id: 1 }).delete()
.then(affectedRows => console.log('Deleted', affectedRows, 'rows'))
.catch(err => console.error(err));
Errors
Common errors & fixes
Cannot find module 'node-mysql-promise'
Package not installed or name misspelled.
fixRun: npm install node-mysql-promise
TypeError: mysql.table is not a function
Using the constructor directly instead of calling createConnection to get an instance.
fixCorrect usage: const mysql = Mysql.createConnection({...}); Audit
Dependencies
mysqlrequiredUnderlying MySQL driver; bundled as a dependency