Questions tagged [sql-parser]

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

129 questions
0
votes
2 answers

RegEx to parse stored procedure and object names from DDL in a .sql file C#

I have a .sql file which may contain DDL definitions of several stored procedures, alter statements for Tables, Triggers, Views etc It could have statements like these : CREATE PROC / CREATE PROCEDURE ALTER PROC / ALTER PROCEDURE DROP PROC / DROP…
StackThis
  • 1,262
  • 1
  • 14
  • 23
-1
votes
1 answer

How to extract all the columns mentioned in a sql query along with the values mentioned in all the conditions in Python

How to extract all the columns mentioned in a sql query along with the values mentioned in all the conditions in Python. Lets say we have the following query. SELECT CASE WHEN grade=90 THEN "A1" WHEN grade=80 THEN "B1" WHEN grade=70 THEN…
-1
votes
2 answers

Handling different escaping sequences?

I'm using ANTLR with Presto grammar in order to parse SQL queries. This is the original string definition I've used to parse queries: STRING : '\'' ( '\\' . | ~[\\'] // match anything other than \ and ' | '\'\'' …
Nir99
  • 185
  • 3
  • 15
-1
votes
1 answer

Regex that remove painting logic and just keep the column name

I have below String and I want to remove formatting and keep just column name. Can someone suggest regex for this please? "XYZ_Col,to_timestamp(CREATE_DT,'yyyyMMdd HHmmss')CREATE_DT,ABC_Col,DEF_Col" to "XYZ_Col,CREATE_DT,ABC_Col,DEF_Col" Thanks in…
dileepvarma
  • 508
  • 2
  • 7
  • 30
-1
votes
1 answer

VBA: translate parsed structure to PostgreSQL

I'm looking to translate parsed structure to PostgreSQL. Hopefully, I am asking this correctly. Is there code out there to do this already? For more color, the need arose from this…
mountainclimber11
  • 1,339
  • 1
  • 28
  • 51
-1
votes
1 answer

Find below patterns in a text

In the broader term, I need to parse SQL procedures and find what tables and columns the proc depends on. To do it, I am trying to search regex. Example: from table db..tb where tb.column2 = "N" AND column 1 in ("ab","cd") It should…
-2
votes
1 answer

Parse SQL Query string to get a map of values

I have a java project where PreparedStatements are not being used in any of the SQL query. Now I want to implement PreparedStatements for all those queries. Instead of modifying each query by putting '?' , I want to write a function which takes SQL…
shashank
  • 65
  • 6
-2
votes
2 answers

Python Regex matcher until two characters like a OR condition

My question is quite simple I'm trying to come up with a RE to select any set of words or statement in between two characters. For example is the strings are something like this : ') as whatever ' and it can also look like ') as…
Chandra Kanth
  • 427
  • 5
  • 14
-2
votes
1 answer

Stimulate SQL like query tool in python/C++

Implement SQL like query tool where from STDIN following things have to be read in the given order:- 1. Number of rows of the table (n) and Number of queries (q). 2. Table fields separated by Comma. 3. n line containing table rows of the table 4. q…
1 2 3
8
9