# jovo-db-mysql

> > To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-db-mysql

Latest version **3.6.1** (published 2022-02-17) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install jovo-db-mysql
pnpm add jovo-db-mysql
yarn add jovo-db-mysql
bun add jovo-db-mysql
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.6.1 |
| Published | 2022-02-17 |
| First published | 2018-12-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 30.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jovotech |
| Maintainers | jovotech |

## Links

- npm: https://www.npmjs.com/package/jovo-db-mysql
- npm.io page: https://npm.io/package/jovo-db-mysql

## Dependencies (4)

- [mysql](https://npm.io/package/mysql.md) ^2.16.0
- [jovo-core](https://npm.io/package/jovo-core.md) ^3.6.1
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2

## Recent versions

- 3.6.1 (latest) — 2022-02-17
- 2.0.2 (beta) — 2018-12-20
- 2.0.1-alpha.13 (alpha) — 2018-12-10
- 3.6.0 — 2021-11-18
- 3.5.1 — 2021-03-26
- 3.5.0 — 2021-02-22
- 3.4.1 — 2021-02-09
- 3.4.0 — 2021-02-04
- 3.3.1 — 2021-01-27
- 3.3.0 — 2020-12-03
- 3.2.2 — 2020-11-20
- 3.2.1 — 2020-11-10
- 3.2.0 — 2020-10-29
- 3.1.5 — 2020-10-23
- 3.1.4 — 2020-10-16
- … 78 more at https://npm.io/package/jovo-db-mysql/versions

## README

# MySQL Database Integration

> To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-db-mysql

Learn how to store user specific data of your Alexa Skills and Google Actions to a MySQL database.

* [Introduction](#introduction)
* [Configuration](#configuration)


## Introduction

The MySQL database integration allows you to store user specific data into this widely adopted relational database. 


## Configuration

Download the package like this:

```sh
$ npm install --save jovo-db-mysql
```

MySQL database integration can be enabled in the `src/app.js` file like this:

```javascript
// @language=javascript

// src/app.js

const { MySQL } = require('jovo-db-mysql');

// Enable DB after app initialization
app.use(new MySQL());

// @language=typescript

// src/app.ts

import { MySQL } from 'jovo-db-mysql';

// Enable DB after app initialization
app.use(new MySQL());
```

In your `config.js` file, you can set the `db` configuration like this:

```javascript
// @language=javascript

// src/config.js

module.exports = {
    
    db: {
        MySQL: {
            tableName: 'yourTableName',
            connection: {
                host: process.env.MYSQL_ADDR || 'localhost',
                port:  process.env.MYSQL_PORT || '9000',
                user: process.env.MYSQL_USER || 'user',
                password: process.env.MYSQL_PASSWORD || 'password',
                database: process.env.MYSQL_DATABASE || 'jovoapp',
                },
        },
    },

    // ...

};

// @language=typescript

// src/config.ts

const config = {
    
    db: {
        MySQL: {
            tableName: 'yourTableName',
            connection: {
                host: process.env.MYSQL_ADDR || 'localhost',
                port:  process.env.MYSQL_PORT || '9000',
                user: process.env.MYSQL_USER || 'user',
                password: process.env.MYSQL_PASSWORD || 'password',
                database: process.env.MYSQL_DATABASE || 'jovoapp',
                },
        },
    },

    // ...

};
```

This is the default configuration for MySQL, if not specified otherwise:

```javascript
// @language=javascript

// src/config.js

module.exports = {
    
    db: {
        MySQL: {
            tableName: 'users',
            primaryKeyColumn: 'userId',
            dataColumnName: 'userData',
            connection: {},
        },
    },

    // ...

};

// @language=typescript

// src/config.ts

const config = {
    
    db: {
        MySQL: {
            tableName: 'users',
            primaryKeyColumn: 'userId',
            dataColumnName: 'userData',
            connection: {},
        },
    },

    // ...

};
```

Once the configuration is done, the MySQL database integration will create a table in your Database on the first read/write attempt.

---
_Source: https://npm.io/package/jovo-db-mysql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
