5.0.0 • Published 2 years ago

marv-mysql-driver v5.0.0

Weekly downloads
147
License
ISC
Repository
github
Last release
2 years ago

NPM version NPM downloads Node.js CI Maintainability Test Coverage

marv-mysql-driver

A mysql driver for marv

Prerequisites

One of:

marv-mysql-driver will automatically use whichever library you have installed but does not package either of these libraries. Please read the troubleshooting notes if using mysql with MySQL 8.0 (or above).

Installation

npm i marv marv-mysql-driver

Usage

migrations/
  |- 001.create-table.sql
  |- 002.create-another-table.sql

Promises

const marv = require('marv/api/promise'); // <-- Promise API
const driver = require('marv-mysql-driver');
const directory = path.resolve('migrations');
const connection = {
  // Properties are passed straight mysql.createConnection
  host: 'mysql.example.com',
  multipleStatements: true    // See https://www.npmjs.com/package/mysql#multiple-statement-queries
};

const migrations = await marv.scan(directory);
await marv.migrate(migrations, driver({ connection });
// Profit :)

Callbacks

const marv = require("marv/api/callback"); // <-- Callback API
const driver = require("marv-mysql-driver");
const directory = path.resolve("migrations");
const connection = {
  // Properties are passed straight [mysql|mysql2].createConnection
  host: "mysql.example.com",
  multipleStatements: true, // See https://www.npmjs.com/package/mysql#multiple-statement-queries
};

marv.scan(directory, (err, migrations) => {
  if (err) throw err;
  // Connection properties are passed straight [mysql|mysql2].createConnection
  marv.migrate(migrations, driver({ connection }), (err) => {
    if (err) throw err;
    // Profit :)
  });
});

Troubleshooting

Client does not support authentication protocol requested by server; consider upgrading MySQL client

MySQL v8 changed the default authentication plugin to caching_sha2_password, which, at time of writing is not supported by mysql. Therefore MySQL v8 users either need to change the default authentication plugin back to mysql_native_password or install mysql2.

MySQL v5 users can use either mysql or mysql2.

Testing

npm install
npm run mysql5
npm run mysql8
npm run mysql8-native-password
sleep 30
npm test
5.0.0

2 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.2.0

8 years ago

0.1.0

8 years ago