Questions relating to code, libraries, or applications that parse SQL-style query languages.
Questions tagged [sql-parser]
129 questions
1
vote
2 answers
SQL Query parser for Java
I am looking for SQL query parser for MySQL queries. Using which I can parse the query, modify the query object and print back modified query
JSQL Parser was exactly what I needed but It has 2 main issues while escaping single quote inside column…

user1228785
- 512
- 2
- 6
- 19
1
vote
4 answers
SQL parser to alter table name
I have a SQL query:
select
t1.name, t2.address
from
Table1 t1
inner join
Table2 t2 on t1.id = t2.id;
and a map:
Map map = new HashMap();
map.put("testTable", "hive.DB1");
map.put("testTable",…

Dev
- 13,492
- 19
- 81
- 174
1
vote
1 answer
parsing SQL with python to find specific statements
I am using sqlparse to try and find specific statements.
code:
import sqlparse
text = 'SELECT * FROM dbo.table'
parse = sqlparse.parse(text)
pizza = [t for t in parse[0].tokens if t.ttype in (sqlparse.tokens.Keyword)]
I get
[

KillerSnail
- 3,321
- 11
- 46
- 64
1
vote
2 answers
JSqlParser how to split an Expression
Suppose I have an expression of the format
a>10 and b>20 and c>30
I want to get a list of expressions as follows
a>10
b>20
c>30
If I use the expression visitor pattern, for the AndExpression visitor, I wrote something like
public void…

Archana
- 79
- 1
- 7
1
vote
0 answers
Extracting SubQuery details using SQLQueryParserManager of Eclipse DTP
I am using eclipse SQLQueryParserManager to extract table name and column names from a sql query. I am getting correct details if I use normal query. But when I use subquery within a query, I am not able to get details of subquery.
Here is what I…

Mohit Chawda
- 53
- 1
- 1
- 8
1
vote
1 answer
c# sqlparser (gudusoft) retrieving an string property from object: too slow
I'm using a sqlparser(c#) provided by gudusoft (sqlparser.com), not sure anyone have used it before.
The sqlparser provides a parser object to which you can input a sql string. Then by calling the parse() method, you can get all the tokens, labels…

cheng
- 6,596
- 6
- 25
- 27
1
vote
1 answer
Using Derby to parse SQL without real tables?
I am new to Derby, and am trying to determine if the SQL parser in it can be used apart from a real database. For example, I want to be able to get a list of the tables referenced in an SQL statement. I believe this can be done by getting the…

user2183260
- 11
- 1
1
vote
1 answer
Regular expression to detect hidden DML(insert, update, delete) statements in a DDL(create, alter, drop) .sql script
UPDATE: To make this question easier. I have changed the string and
now you don't have to worry about BEGIN END at all. Instead I now have only GO statements as
terminators. I hope I will get some answers from other people now
I need to write…

StackThis
- 1,262
- 1
- 14
- 23
1
vote
1 answer
Better to parse name values or combine
I have two different tables, with the name values being stored in different manners...
For example one field is:
inventorName
John C. Smith
While in the other table the fields are:
Inventorfirst | InventorLast
John C. | Smith
The…

Johnny B
- 420
- 1
- 5
- 14
0
votes
1 answer
spark sql parser for complex queries
I am trying to build a sql parser that will be parsing complicated sql queries
for example, below is an example of one of such queries:
select * from (select a.a, a.b from db.tmp_table1 a JOIN db.tmp_table2 b
where a.c = b.c
and a.d =…
0
votes
0 answers
How to validate SQL query with unbalanced quotes
We want to parse the mysql query in python project and detect wrong query based on unbalanced quotes or wrong quotes placement
or column filtered values having wrong quotes
Example:
"select * from city where name='x and type=y;" -> Wrong…

Vaibhav
- 1,154
- 10
- 26
0
votes
0 answers
Antlr PLSQL, How to get positions of expressions
I want to use the antlr PLSQL parser to manipulate my sql code that comes from Oracle Forms.
Therefore I created all needed Java classes and now have this Main code that works fine:
CharStream charStream = CharStreams.fromString("CREATE FUNCTION…

Alena
- 1
- 1
0
votes
0 answers
Python Sqlparse: How to get the boolean status if sql query is not in correct format
I have a use case where I need to check the format of the sql query before sending to the the database for execution.
If sql query is not in correct format sqlparse should return the false status, if it is in correct format it should return true…

Rahul Neekhra
- 780
- 1
- 9
- 39
0
votes
0 answers
How can we parse the SQL query with DATE as the identifier using Apache Calcite?
I am trying to parse the SQL query which is having DATE as the identifier using Apache Calcite. DATE is a reserve word in calcite and due to this it is failing to parse the query with the below error:
Exception:…

Amit B
- 11
- 2
0
votes
0 answers
How to loop through multiple queries seperated by ; in the python
I am working on a python code that will read multiple files in a directory and check all the queries in those files. The code will perform two checks:
it will check if the table name in a CREATE TABLE query is enclosed in double quotes and give a…

gourav saini
- 21
- 3