-
Notifications
You must be signed in to change notification settings - Fork 16
Examples MySQL Connection
Thiago Delgado Pinto edited this page Dec 13, 2017
·
2 revisions
The MySQL driver connects to a local or remote MySQL server over an IP connection. The MySQL driver supports transactions.
mysql://[[username]:[password]@]host[:port]/database
const Connection = require('database-js2').Connection;
var connection = new Connection('mysql://user:password@localhost/data');
var Connection = require('database-js2').Connection;
(async function() {
let connection, statement, rows;
try {
connection = new Connection('mysql://my_secret_username:my_secret_password@localhost:3306/my_top_secret_database');
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 {
if (connection) {
await connection.close();
}
}
})();