Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
mysql
Advanced tools
Readme
A node.js module implementing the MySQL protocol.
I'm working on this driver because I need it for my own startup (transloadit.com), but it's a big project (~100-200 hours) with obvious benefits to other companies who are using MySql.
So if your company could benefit from a well-engineered node.js mysql driver, I would greatly appriciate any sponsorship you may be able to provide. All sponsors will get lifetime display in this readme, priority support on problems, and votes on roadmap decisions. If you are interested, contact me at felix@debuggable.com for details.
Of course I'm also happy about code contributions. If you're interested in working on features, just get in touch so we can talk about API design and testing.
npm install mysql
var Client = require('mysql').Client,
client = new Client();
client.user = 'root';
client.password = 'root';
client.connect();
client.query('CREATE DATABASE '+TEST_CONFIG.database, function() {
if (err && err.errorNumber != Client.ERROR_DB_CREATE_EXISTS) {
throw err;
}
});
// If no callback is provided, any errors will be emitted as `'error'`
// events by the client
client.query('USE '+TEST_CONFIG.database);
client.query(
'CREATE TEMPORARY TABLE '+TEST_TABLE+
'(id INT(11) AUTO_INCREMENT, '+
'title VARCHAR(255), '+
'text TEXT, '+
'created DATETIME, '+
'PRIMARY KEY (id));',
);
client.query(
'INSERT INTO '+TEST_TABLE+' '+
'SET title = ?, text = ?, created = ?',
['super cool', 'this is a nice text', '2010-08-16 10:00:23'],
);
var query = client.query(
'INSERT INTO '+TEST_TABLE+' '+
'SET title = ?, text = ?, created = ?',
['another entry', 'because 2 entries make a better test', '2010-08-16 12:42:15']
);
client.query(
'SELECT * FROM '+TEST_TABLE,
gently.expect(function selectCb(err, results, fields) {
if (err) {
throw err;
}
console.log(results);
console.log(fields);
client.end();
})
);
Creates a new client instance. Any client property can be set using the
options
object.
The host to connect to.
The port to connect to.
The username to authenticate as.
The password to use.
The name of the database to connect to (optional).
Prints incoming and outgoing packets, useful for development / testing purposes.
Connection flags send to the server.
Initiates a connection to the specified host server.
Sends a sql
query to the server. '?'
characters can be used as placeholders
for an array of params
that will be safely escaped before sending the final
query.
This method returns a Query
object which can be used to stream incoming row
data.
Allows to safely insert a list of params
into a sql
string using the
placeholder mechanism described above.
Escapes a single val
for use inside of a sql string.
Closes the connection to the server.
When the client has no callback / delegate for an error, it is emitted with this event instead.
Query objects are not meant to be invoked manually. To get a query object, use
the client.query
API.
Emitted when mysql returns an error packet for the query.
Emitted upon receiving a field packet from mysql.
Emitted upon receiving a row. An option for streaming the contents of the row itself will be made available soon.
Emitted once the query is finished. In case there is no result set, a result
parameter is provided which contains the information from the mysql OK packet.
At this point the module is ready to be tried out, but a lot of things are yet to be done:
node-mysql is licensed under the MIT license.
FAQs
A node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.
We found that mysql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).