# anysql

> Modern minimal API for any SQL database

Latest version **0.2.1** (published 2016-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install anysql
pnpm add anysql
yarn add anysql
bun add anysql
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2016-03-30 |
| First published | 2015-09-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Manuel Vila |
| Maintainers | mvila |

## Links

- npm: https://www.npmjs.com/package/anysql
- Repository: https://github.com/object-layer/anysql
- Homepage: https://github.com/object-layer/anysql#readme
- Issues: https://github.com/object-layer/anysql/issues
- npm.io page: https://npm.io/package/anysql

## Dependencies (3)

- [anysql-mysql](https://npm.io/package/anysql-mysql.md) ^0.2.1
- [anysql-websql](https://npm.io/package/anysql-websql.md) ^0.4.1
- [anysql-cordova-sqlite](https://npm.io/package/anysql-cordova-sqlite.md) ^0.5.1

## Recent versions

- 0.2.1 (latest) — 2016-03-30
- 0.2.0 — 2016-01-15
- 0.1.6 — 2015-11-12
- 0.1.5 — 2015-11-12
- 0.1.4 — 2015-11-12
- 0.1.3 — 2015-10-21
- 0.1.2 — 2015-09-29
- 0.1.1 — 2015-09-25

## README

# AnySQL [![Build Status](https://travis-ci.org/object-layer/anysql.svg?branch=master)](https://travis-ci.org/object-layer/anysql)

Modern minimal API for any SQL database.

### Features

- Unified API for several database engines.
- No need to manage connections, just query the database.
- Easy transactions with automatic begin/commit/rollback.
- Asynchronous functions return promises, feel free to handle them with ES7 async/await feature.

### Supported databases

- MySQL
- WebSQL (Chrome and Safari)
- SQLite (via [CordovaSQLitePlugin](https://www.npmjs.com/package/cordova-sqlite-plugin))
- More to come (PR welcome!)

## Installation

```
npm install --save anysql
```

## Usage

### Simple query

```javascript
import AnySQL from 'anysql';

let anysql = new AnySQL('mysql://test@localhost/test');
let rows = await anysql.query('SELECT ? + ? AS solution', [2, 3]);
console.log(rows[0].solution); // => 5
```

### Transactions

```javascript
import AnySQL from 'anysql';

let anysql = new AnySQL('mysql://test@localhost/test');
await anysql.transaction(async function(transaction) {
  let rows = await transaction.query('SELECT ...');
  // ...
  await transaction.query('UPDATE ...');
  // ...
  // if no error has been thrown, the transaction is automatically committed
});
```

## License

MIT

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