node-sql-parser | Parse simple SQL statements into an abstract syntax tree | SQL Database library
kandi X-RAY | node-sql-parser Summary
kandi X-RAY | node-sql-parser Summary
Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of node-sql-parser
node-sql-parser Key Features
node-sql-parser Examples and Code Snippets
Community Discussions
Trending Discussions on node-sql-parser
QUESTION
My aim is to parse SQL (specifically Hive) statements with javascript, preferably Nodejs. I started out with node-sql-parser which looked promising. However I found quite a few cases where the parser did not recognize valid SQL like several nested functions on a column in a select clause, and multiple AND clauses in SQL that had lots of joins, unions, etc. (I've logged as issue but it will take some time).
I decided to look at Antlr v4. I followed the getting started steps with Hive SQL grammar. (https://github.com/apache/hive/blob/master/hplsql/src/main/antlr4/org/apache/hive/hplsql/Hplsql.g4); I generated parsers lexers and listeners using Antlr's generation for JavaSCript - all good so far. Then I tried a simple test as below:
...ANSWER
Answered 2020-Nov-23 at 15:49As mentioned in the comments by kaby76: the grammar contains target specific (Java) code. You need to replace all Java code between {
and }?
with TypeScipt code.
For example, this Java code:
QUESTION
I am trying to parse an sql query in nodejs using node-sql-parser.
...ANSWER
Answered 2020-Feb-19 at 10:25You are logging it as an object that is why you see object in that. You need to JSON.stringify(ast)
the object before consoling to see everything.
Regarding finding all the operators, you could use this code
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-sql-parser
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page