sql-summary
Summarize any SQL query
Last updated 8 years ago by watson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install sql-summary 
SYNC missed versions from official npm registry.

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:

SELECT col1, col2 FROM table_name WHERE id=1

The following summary string is produced:

SELECT FROM table_name

npm Build status js-standard-style

Installation

npm install sql-summary

Usage

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

Current Tags

  • 1.0.1                                ...           latest (8 years ago)

2 Versions

  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 24
Today 0
This Week 5
This Month 15
Last Day 1
Last Week 1
Last Month 8
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE