Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
database-js-mysql
Advanced tools
MySQL wrapper for database-js
Database-js-mysql is a wrapper around the mysql package by Doug Wilson. It is intended to be used with the database-js package. However it can also be used in stand alone mode. The only reason to do that would be to use Promises.
npm install database-js-mysql
var mysql = require('database-js-mysql');
(async () => {
let connection, rows;
connection = mysql.open({
Hostname: localhost,
Port: 3306,
Username: 'my_secret_username',
Password: 'my_secret_password',
Database: 'my_top_secret_database'
});
try {
rows = await connection.query("SELECT * FROM tablea WHERE user_name = 'not_so_secret_user'");
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();
var Database = require('database-js').Connection;
(async () => {
let connection, statement, rows;
connection = new Database('mysql://my_secret_username:my_secret_password@localhost:3306/my_top_secret_database');
try {
statement = await connection.prepareStatement("SELECT * FROM tablea WHERE user_name = ?");
rows = await statement.query('not_so_secret_user');
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();
If you need to support SSL for your MySQL connection (for AWS RDS, for example), you can add extra params:
var Database = require('database-js').Connection;
(async () => {
let connection, statement, rows;
connection = new Database('mysql://my_secret_username:my_secret_password@localhost:3306/my_top_secret_database?ssl[ca]=%2Fpath%2Fto%2Fca.pem');
try {
statement = await connection.prepareStatement("SELECT * FROM tablea WHERE user_name = ?");
rows = await statement.query('not_so_secret_user');
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();
Note that ssl[ca]
, ssl[key]
and ssl[cert]
will be checked for file paths
and loaded:
// The query parameters are loaded into an 'options' object
if (options.ssl.ca && fs.existsSync(options.ssl.ca)) {
options.ssl.ca = fs.readFileSync(options.ssl.ca);
}
FAQs
database-js wrapper for MySQL
The npm package database-js-mysql receives a total of 4,788 weekly downloads. As such, database-js-mysql popularity was classified as popular.
We found that database-js-mysql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.