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.
sy-node-mysql
Advanced tools
a simple mysql builder
$ npm install sy-node-mysql --save
多个config可以有相同的name, 其中只能有一个可写库,可以有多个只读库
const config = [
{
"name": 'TEST_DATABASE', // config name
"database": "db_one",
"port": 3306,
"host": "192.168.0.1",
"user": "root",
"password": "root",
"charset": "UTF8MB4_GENERAL_CI",
"connectionLimit": 50
},
{
"name": 'TEST_DATABASE',
"readonly": true, // mark as readonly
"database": "db_one",
"port": 3306,
"host": "192.168.1.1",
"user": "root",
"password": "root",
"charset": "UTF8MB4_GENERAL_CI",
"connectionLimit": 100,
},
{
"name": "TEST_DATABASE_TWO",
"readonly": false,
"database": "db_two",
"port": 3306,
"host": "192.168.0.2",
"user": "root",
"password": "root",
"charset": "UTF8MB4_GENERAL_CI",
"connectionLimit": 100,
"timezone": "Z",
"bigNumberStrings": true,
"supportBigNumbers": true
}
]
const MySQL = require('bi-node-mysql');
const mysql = new MySQL(config);
const pool = mysql.get('TEST_DATABASE');
await pool.query(sql, opts);
//the same as
await mysql.query(sql, opts, 'TEST_DATABASE');
const res = await mysql.select('person', { where: { id: 100 } }, 'TEST_DATABASE', true);
const opts = {
fields: ['age', 'name'],
where: { aa: 1 },
literalWhere: ['id in (?)'],
group: 'city',
having: ['age >= ?'],
orders: [['age', 'desc'], ['name', 'asc']],
limit: 10,
offset: 5,
params: [[100, 101], 10]
};
const res = await mysql.select('person', opts, 'TEST_DATABASE');
const sql = `select * from person where age > ? and age < ?`;
const params = [10, 20];
const res = await mysql.query(sql, params, 'TEST_DATABASE');
const opts = {
update: { name: 'Tom', age: 18 },
literalUpdate: ['score = score + ?'],
where: { id: 100 },
literalWhere: [ 'age > ?' ],
params: [20, 20]
};
await mysql.update('db_one.person', opts, 'TEST_DATABASE');
const opts = {
insert: { name: 'Tom', age: 18 },
onUpdate: { age: 18 }
};
await mysql.insert('person', opts, 'TEST_DATABASE');
const transaction = await mysql.beginTransaction('TEST_DATABASE');
try {
const opts1 = {
update: { name: 'Tom', age: 18 },
where: { id: 100 },
};
await transaction.update('person', opts1);
const opts2 = {
update: { name: 'John', age: 16 },
where: { id: 10 },
};
await transaction.update('person', opts2);
await transaction.commit();
} catch (err) {
await transaction.rollback();
throw err;
}
FAQs
a simple mysql builder
The npm package sy-node-mysql receives a total of 14 weekly downloads. As such, sy-node-mysql popularity was classified as not popular.
We found that sy-node-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.