Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guidesmiths/marv-mysql-driver
A mysql marv driver implementation
https://github.com/guidesmiths/marv-mysql-driver
mysql nodejs
Last synced: 3 months ago
JSON representation
A mysql marv driver implementation
- Host: GitHub
- URL: https://github.com/guidesmiths/marv-mysql-driver
- Owner: guidesmiths
- License: isc
- Created: 2016-09-08T20:33:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T18:22:21.000Z (about 2 years ago)
- Last Synced: 2024-09-28T15:41:52.605Z (4 months ago)
- Topics: mysql, nodejs
- Language: JavaScript
- Homepage:
- Size: 334 KB
- Stars: 2
- Watchers: 13
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM version](https://img.shields.io/npm/v/marv-mysql-driver.svg?style=flat-square)](https://www.npmjs.com/package/marv-mysql-driver)
[![NPM downloads](https://img.shields.io/npm/dm/marv-mysql-driver.svg?style=flat-square)](https://www.npmjs.com/package/marv-mysql-driver)
[![Node.js CI](https://github.com/acuminous/tripitaka/workflows/Node.js%20CI/badge.svg)](https://github.com/guidesmiths/marv-mysql-driver/actions?query=workflow%3A%22Node.js+CI%22)
[![Maintainability](https://api.codeclimate.com/v1/badges/621e711c2cd6077f5ad3/maintainability)](https://codeclimate.com/github/guidesmiths/marv-mysql-driver/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/621e711c2cd6077f5ad3/test_coverage)](https://codeclimate.com/github/guidesmiths/marv-mysql-driver/test_coverage)# marv-mysql-driver
A mysql driver for [marv](https://www.npmjs.com/package/marv)
## Prerequisites
One of:
- [mysql](https://www.npmjs.com/package/mysql)
- [mysql2](https://www.npmjs.com/package/mysql2)marv-mysql-driver will automatically use whichever library you have installed **but does not package either of these libraries**. Please read the [troubleshooting](#troubleshooting) notes if using [mysql](https://www.npmjs.com/package/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
```js
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
```js
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](https://dev.mysql.com/doc/refman/8.0/en/pluggable-authentication.html) to `caching_sha2_password`, which, at time of writing is not supported by [mysql](https://github.com/mysqljs/mysql/issues/2001). Therefore MySQL v8 users either need to [change](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin) the default authentication plugin back to `mysql_native_password` or install [mysql2](https://www.npmjs.com/package/mysql2).
MySQL v5 users can use either [mysql](https://www.npmjs.com/package/mysql) or [mysql2](https://www.npmjs.com/package/mysql2).
## Testing
```bash
npm install
npm run mysql5
npm run mysql8
npm run mysql8-native-password
sleep 30
npm test
```