All Projects → justinkenel → js-sql-parse

justinkenel / js-sql-parse

Licence: other
A nearley based sql parser and analyzer

Programming Languages

javascript
184084 projects - #8 most used programming language
Nearley
35 projects

JS SQL Parse

Status

Currently a work in progress: The end goal is to be able to parse and analyze general sql queries.

Dependencies

JS SQL Parse uses Nearley to parse strings. The grammar is defined in sql.ne

Tests

Run tests using npm run test

Use

The test files in ./tests are the best place to see examples of use. A basic example is:

const parser = require('js-sql-parser');
const result = parser.parse('select * from test_table');

The result of the parse method will have the following fields:

  • referencedTables: a list of tables used in the query
  • createdTables: a list of tables created in the query
  • sourceTables: a list of tables sourced in subqueries and joins
  • operation: the operation defined in the query - currently only select and create_view are supported
  • parsed: the resulting parse tree
  • joins: a list of joins within the query, and the columns used
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].