database-js-mysql
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.
Install
npm install database-js-mysql
Usage
Stand Alone
var mysql = ; async { let connection rows; connection = mysql; try rows = await connection; console; catch error console; finally await connection; };
With Database-js
var Database = Connection; async { let connection statement rows; connection = 'mysql://my_secret_username:my_secret_password@localhost:3306/my_top_secret_database'; try statement = await connection; rows = await statement; console; catch error console; finally await connection; };
With SSL
If you need to support SSL for your MySQL connection (for AWS RDS, for example), you can add extra params:
var Database = Connection; async { let connection statement rows; connection = 'mysql://my_secret_username:my_secret_password@localhost:3306/my_top_secret_database?ssl[ca]=%2Fpath%2Fto%2Fca.pem'; try statement = await connection; rows = await statement; console; catch error console; finally await connection; };
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' objectif optionssslca && fs optionssslca = fs;