# sql-summary

> Summarize any SQL query

Latest version **1.0.1** (published 2018-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install sql-summary
pnpm add sql-summary
yarn add sql-summary
bun add sql-summary
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-07-25 |
| First published | 2015-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Thomas Watson Steen |
| Maintainers | qard, watson |
| Keywords | sql, summary, query, log, logging, analyze |

## Links

- npm: https://www.npmjs.com/package/sql-summary
- Repository: https://github.com/elastic/sql-summary
- Issues: https://github.com/elastic/sql-summary/issues
- npm.io page: https://npm.io/package/sql-summary

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-07-25
- 1.0.0 — 2015-10-16

## README

# sql-summary

Summarize any SQL query.

This JavaScript module will analyse an SQL query and return a very brief
summary string containing:

- Main verb used (`SELECT`, `INSERT`, `UPDATE` etc.)
- Potentially the type operated on (`TABLE`, `DATABASE` etc.)
- The name of the primary table or database operated on

For example, if given the following SQL query:

```sql
SELECT col1, col2 FROM table_name WHERE id=1
```

The following summary string is produced:

```sql
SELECT FROM table_name
```

[![npm](https://img.shields.io/npm/v/sql-summary.svg)](https://www.npmjs.com/package/sql-summary)
[![Build status](https://travis-ci.org/elastic/sql-summary.svg?branch=master)](https://travis-ci.org/elastic/sql-summary)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

## Installation

```
npm install sql-summary
```

## Usage

```js
var sqlSummary = require('sql-summary')

var query = 'UPDATE table_name SET col1=1, col2=2 WHERE id=1'

console.log('Running query:', sqlSummary(query)) // => 'Running query: UPDATE table_name'
db.query(query, function (err, result) {
  // ...
})
```

## Use-cases

- In a web-server log output the type of queries used without going into
  too much details about each query
- Group similar queries operating on the same tables

## License

[MIT](https://github.com/elastic/sql-summary/blob/master/LICENSE)

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