sync-mysql

3.0.1 • Public • Published

sync-mysql

Make synchronous queries to a mysql database

Build Status Dependency Status NPM version

Installation

npm install sync-mysql --save

Usage

var MySql = require('sync-mysql');
 
var connection = new MySql({
  host: 'localhost',
  user: 'me',
  password: 'secret'
});
 
const result = connection.query('SELECT 1 + 1 AS solution');
assert(result[0].solution === 2);

API

connection.getRecord(tableName, id)

Assuming that the table passed has an id column, get the record with that id.

connection.query(str, values)

Return an array of objects from a SQL query. The query may optionally contain ?s to be replaced with escaped values from values which should be an array.

connection.call(name, args)

Call a database procedure. If it returns only one set of values, that set of values is returned as an array of objects. If it returns multiple sets of values then they are returned as an array.

License

MIT

/sync-mysql/

    Package Sidebar

    Install

    npm i sync-mysql

    Weekly Downloads

    850

    Version

    3.0.1

    License

    MIT

    Last publish

    Collaborators

    • forbeslindesay