JSPM

sql-summary

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 337453
  • Score
    100M100P100Q182177F
  • License MIT

Summarize any SQL query

Package Exports

  • sql-summary

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sql-summary) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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:

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