Questions tagged [sql-parser]

Questions relating to code, libraries, or applications that parse SQL-style query languages.

129 questions
21
votes
4 answers

How to parse / tokenize an SQL statement in Node.js

I'm looking for a way to parse / tokenize SQL statement within a Node.js application, in order to: Tokenize all the "basics" SQL keywords defined in the ISO/IEC 9075 standard or here. Validate the SQL syntax. Find out what the query is gonna do…
Yves M.
  • 29,855
  • 23
  • 108
  • 144
12
votes
1 answer

SQL Parsing library for Python

We need a SQL parsing or decomposing library for Python. We would like to be able to input a SQL text query and then get the query parts back as a result. It doesn't need to be fancy, or anything, but we would like to avoid doing the parsing…
Juan Carlos Coto
  • 11,900
  • 22
  • 62
  • 102
9
votes
3 answers

Adding a User-Defined Function to Calcite

I need to add a user-defined function to Calcite that takes an integer as a parameter and returns an integer. public class SquareFunction { public int eval(int a) { return a*a; } } and the relevant code that…
9
votes
1 answer

Visualizing what an sql statement is using

I have an SQL statement that uses a few tables built via another set of statements which in turn are each built by more sets of statements etc. to about 8 degrees fanning out to about 25 tables (it gets wider in the 4th degree but that level…
dlamblin
  • 43,965
  • 20
  • 101
  • 140
8
votes
3 answers

How to retrieve table and column names from SQl using JSQLPARSE

I am using JSQLPARSER for the first time. I have some SQL files which come dynamically, i need to read table and column names from that SQL. After lot of googling I tried with JSQLPARSER. I am trying to read column names from the file but I am…
Navyah
  • 1,660
  • 10
  • 33
  • 58
6
votes
1 answer

Parsing SQL Query into a DOM-like tree to enable automatic permutation?

I have a large and complicated sql view that I am attempting to debug. There is a record not showing in the view and I need to determine which clause or join is causing the record to now show up. At the moment I am doing this in a very manual way,…
Ben Page
  • 3,011
  • 4
  • 35
  • 37
6
votes
1 answer

How do I install Microsoft.SqlServer.Management.SqlParser?

My c# installer project came up with a load of warnings when I rebuilt it on a new machine. The warnings were of the ilk that they were looking for version 11.0.0.0 of a dll where only version 10.0.0.0 existed. This I found was due to the version of…
sr28
  • 4,728
  • 5
  • 36
  • 67
4
votes
1 answer

Speed of Microsoft.Data.Schema.ScriptDom Parser

I'm using the Microsoft.Data.Schema.ScriptDom and Microsoft.Data.Schema.ScriptDom.Sql libraries to parse SQL and add "TOP #" to SQL select statements. We do this to limit the result set in certain situations. I just getting started using the…
Craig Jensen
  • 95
  • 11
3
votes
1 answer

How do I remove comments from an Oracle SQL script using pyparsing in Python 3.x?

I have an oracle sql script containing multiple statements which are separated by ";". I'm trying to remove all comments within this entire script. This includes: single line comments -- till a newline. block comments /* ... */ Additionally, I…
Chowder
  • 96
  • 1
  • 7
3
votes
2 answers

Get internal parse tree of an SQL query

I've found an interesting library libpg_query, which allows to parse any arbitrary Postgres SQL query into an internal parse tree, the way Postgres would actually understand the query. It acts offline, it's a rewrite of Postgres' source code. For…
winwin
  • 958
  • 7
  • 25
3
votes
2 answers

How to parse any SQL get columns names and table name using SQL parser in python3

I am able to get the column names and table name from using sql parse for only simple select SQL's. Can somebody help how can get the column names and table name from any complex SQL's.
Prasad
  • 79
  • 1
  • 4
3
votes
1 answer

Is there any function to parse a complete SQL query in Python?

I am using postgreSQL queries. I want to extract all information from a SQL query, for example sql = " select d_year, s_nation, p_category, sum(lo_revenue - lo_supplycost) as profit from DATES, CUSTOMER, SUPPLIER, PART, LINEORDER where lo_custkey =…
Islacine
  • 105
  • 2
  • 9
3
votes
2 answers

Analyzing SQL Queries

I have a set of MS sql queries (around 500). I have to analyze these queries and find out the most frequently used tables, filter conditions . Is there an easy way to do this. Can we use R to do this? Or some other tool or logic.
sandeep johnson
  • 161
  • 2
  • 7
3
votes
0 answers

Microsoft.SqlServer.SqlManagementObjects aka SMO nuget does not contain Microsoft.SqlServer.Management.SqlParser.dll

I'm using CollationInfo Class for SQL Collation (SQL_Latin1_General_CP1_CS_AS) specific string comparisons (https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.sqlparser.metadata.collationinfo.aspx). Once I installed SMO nuget…
Ketan
  • 31
  • 3
3
votes
2 answers

ANTLR making a grammar for parsing insert/update/delete SQL query

I am new to ANTLR & grammar writing. My requirement is to parse insert/update/delete SQL queries to get details like which table is being update/inserted/deleting a row, list of columns & their values etc. Yes there is a good documentation of ANTLR,…
hemu
  • 3,199
  • 3
  • 44
  • 66
1
2 3
8 9