# @ladc/mysql-adapter

> Connect to MySQL and MariaDB with the LADC API ('mysql' connector).

Latest version **0.22.15** (published 2020-09-05) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install @ladc/mysql-adapter
pnpm add @ladc/mysql-adapter
yarn add @ladc/mysql-adapter
bun add @ladc/mysql-adapter
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.22.15 |
| Published | 2020-09-05 |
| First published | 2020-09-04 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Paleo |
| Maintainers | paleo |
| Keywords | mysql, mariadb, connection, ladc |

## Links

- npm: https://www.npmjs.com/package/@ladc/mysql-adapter
- Repository: https://github.com/paroi-tech/ladc
- Homepage: https://github.com/paroi-tech/ladc/tree/master/mysql-adapter
- Issues: https://github.com/paroi-tech/ladc/issues
- npm.io page: https://npm.io/package/@ladc/mysql-adapter

## Dependencies (1)

- [mysql](https://npm.io/package/mysql.md) ^2.18.1

## Recent versions

- 0.22.15 (latest) — 2020-09-05
- 0.22.14 — 2020-09-04
- 0.22.13 — 2020-09-04
- 0.22.12 — 2020-09-04

## README

# @ladc/mysql-adapter

[![Build Status](https://travis-ci.com/paroi-tech/ladc.svg?branch=master)](https://travis-ci.com/paroi-tech/ladc)
[![npm](https://img.shields.io/npm/dm/@ladc/mysql-adapter)](https://www.npmjs.com/package/@ladc/mysql-adapter)
![Type definitions](https://img.shields.io/npm/types/@ladc/mysql-adapter)
[![GitHub](https://img.shields.io/github/license/paroi-tech/ladc)](https://github.com/paroi-tech/ladc)

[LADC](https://github.com/paroi-tech/ladc/tree/master/ladc) is a common API on top of relational database (SQL) connectors. It can connect to Postgresql, MariaDB / MySQL, SQLite. The API is inspired from PDO and JDBC. It’s named LADC for “a Layer Above Database Connectors”.

This package is a plugin for LADC. It is an adapter for MySQL and MariaDB, using the connector [mysql](https://www.npmjs.com/package/mysql).

## Install

```
npm install @ladc/mysql-adapter ladc
```

## Use a MySQL connection with LADC

How to create a connection:

```js
import ladc from "ladc";
import mysqlAdapter from "@ladc/mysql-adapter";

const cn = ladc({
  adapter: mysqlAdapter({
    mysqlConfig: {
      host: "-my-server-",
      database: "-my-database-",
      user: "-my-user-",
      password: "-my-password-",
    },
  }),
});
```

# Use a MySQL connection with LADC and SQL Bricks

Add the dependencies for SQL Bricks:

```sh
npm install sql-bricks @ladc/sql-bricks-modifier
```

In your code, MySQL requires to set a specific `placeholder` option in SQL Bricks:

```js
import ladc from "ladc";
import mysqlAdapter from "@ladc/mysql-adapter";
import sqlBricksModifier from "@ladc/sql-bricks-modifier";

const cn = ladc({
  adapter: mysqlAdapter({
    mysqlConfig: {
      host: "-my-server-",
      database: "-my-database-",
      user: "-my-user-",
      password: "-my-password-",
    },
  }),
  modifier: sqlBricksModifier({
    toParamsOptions: { placeholder: "?" }, // ← Specific to MySQL
  }),
});
```

Now, use it:

```js
import { select } from "sql-bricks";

async function test(cn) {
  const q = select("col1, col2").from("table1");
  const rows = await cn.all(q);
  console.log(rows);
}
```

## Contribute

With VS Code, our recommanded plugin is:

- **TSLint** from Microsoft (`ms-vscode.vscode-typescript-tslint-plugin`)

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