149 questions
2
votes
1
answer
97
views
jOOQ removes SQL inside ignore comments during execution
I'm using jOOQ with PostgreSQL and want to execute a query with an EXPLAIN (ANALYZE, FORMAT JSON) prefix.
I set the parser settings to ignore comments:
Settings settings = new Settings()
...
0
votes
1
answer
253
views
Parsing Complex SQL Statements to Map Columns, Tables, Databases Being Queried
I have been trying to create a python script that will parse some pretty complex SQL and return a dataframe of all of the columns, tables, and databases being queried as well as section indicators of ...
1
vote
0
answers
67
views
Parsing SQL queries and get select and where clauses using Microsoft.SqlServer.Management.SqlParser
I tried to parse SQL queries using Microsoft.SqlServer.Management.SqlParser librairies.
I didn't find any complete (or updated topics) documentation about it.
So far, here's my code:
Imports Microsoft....
-1
votes
1
answer
225
views
Pinotdb error (pinotdb.exceptions.DatabaseError) {'errorCode': 150... when trying to initialize apache-pinot db from apache-superset
while setting up Apache-Superset (I installed Superset on Ubuntu 22.04 over pypi, for the connector im using pinotdb, to connect Superset to a apache-pinot db.) i encountered following error after ...
0
votes
0
answers
55
views
How can i generate the Flex&Bison target by CMake?
i was writing a sql parser, i use cmake configure my project.
source code directories are as follows:
├── build
├── CMakeLists.txt // root CMakeLists.txt
└── src
├── CMakeLists.txt //...
0
votes
0
answers
68
views
Checking if SQL Query Output Will Be Ordered Based on `ORDER BY` Clause
I'm working on a project where I need to parse SQL queries and determine if the final SQL output will be ordered or not. I am checking based on the presence of an ORDER BY clause.
Here's what I've ...
0
votes
1
answer
139
views
How to get table & their alias names using Microsoft ScriptDom library
Hi I am using Microsoft ScriptDOM parser (Microsoft.SqlServer.TransactSql.ScriptDom) to parse the SQL queries.
For a decision making in my logic I want to know all the table names and their alias in a ...
1
vote
1
answer
448
views
python sqlparse - WHERE clause eats custom keywords
I'm working with sqlparse and defining my own custom keywords for the dialect I'm using, but I'm noticing that if my keyword 'FACET' appears after my WHERE clause, it gets grouped into the WHERE's ...
0
votes
2
answers
100
views
Find a keyword, then display each line until it finds the next keyword in PHP
What I want to do is:
Open a sql file
Find a keyword then display the line
Keep displaying each line until the next keyword
Keep doing 1 - 3 until the end of the file
This is my code but it stops ...
-2
votes
1
answer
392
views
Verify if a Column of a particular SQL Table is present or not from a given Select SQL Query(Oracle) , using Python and no access to Database [closed]
Given a SQL query(Oracle) I want to find if column of a particular table is present in it or not.
I want to achieve this using Python.
I do not have any access to the Database and I needed this for ...
0
votes
0
answers
67
views
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 ...
0
votes
0
answers
254
views
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 ...
1
vote
0
answers
1k
views
Apache Calcite SQL parser not able to parse the SQL query with column or column alias having a number
Example query:
SELECT empid as 3_e FROM EMP;
Error:
Exception: org.apache.calcite.sql.parser.SqlParseException: Encountered "3" at line 1, column 17.
Was expecting one of:
<...
1
vote
1
answer
2k
views
Getting token types in python sqlparse library
I am wokring on SQL code parser in python for further code analysis. I decided to use "sqlparse" python library and after parsing the text I would like to know particular token type such as &...
0
votes
1
answer
117
views
split queries with regex
#i am using regex to split this but i am getting wrong results.
import re
queries ="""
INSERT ignore into persons VALUES (15,'Tom D.', 'Erilchsen',
'Skagen 21', 'Erlangen');
select * ...
0
votes
1
answer
119
views
What is the relevant rules of Flink Window TVF and CEP SQL?
I am trying to parse Flink windowing TVF sql column level lineage, I initial a custom FlinkChainedProgram and set some Opt rules.
Mostly works fine except Window TVF SQL and CEP SQL.
for example, I ...
0
votes
1
answer
1k
views
Invalid expression / Unexpected token While using sqlglot to fetch all the columns used in the where clause
sql_query = "select T.lk1,T1.lk1 as dc_lk1, T.BB_NOW_name,T.City,T.DC_name,T.SKU_code,T.SKU_description,T.Brand,T.Manufacturer,T.From_Date,T.To_date, T1.DC_CMBQ,T1.DC_AMBQ,T1.DC_ICM,T.BB_NOW_CMBQ,...
0
votes
1
answer
920
views
Is there a good way to parse sql case statement?
The goal is to parse the sql statement in Python, and I have some difficulties using sqlparse to parse the case statement. I have tried the method in this link Parse CASE WHEN statements with sqlparse,...
1
vote
0
answers
912
views
Why am I getting antlr.MismatchedTokenException thrown for simple SQL query parsing (.NET)?
Queries are read fine when debugging only My Code. However, when disabling the option in Visual Studio in 'Debug > Options > Enable Just My Code', antlr.MismatchedTokenException is thrown for ...
0
votes
2
answers
2k
views
Parsing two SQL statements using split , the result is incorrect
>>> import sqlparse
>>> t_sql = """create table dmc_o2_test(
... stuid number(38) primary key,
... stuname varchar2(30) not null
... )
...
... select * from ...
1
vote
1
answer
2k
views
Extract JSON representation of SQL query where clause with sqlparse
I'm trying to use python library sqlparse to extract the WHERE condition from a SQL statement and represent it in conditional JSON format. I'm interested only in the SQL condition, so the starting ...
0
votes
2
answers
4k
views
Get and Add WHERE clause in SQL Query Python
I am coding in Python. I have query like this:
SELECT device_os, count(*) FROM warehouse WHERE device_year <= 2016 GROUP BY device_os;
Now, I have some additional filters which are coming ...
1
vote
1
answer
142
views
Anorm replacement of params gives error on usage of aggregate functions
Table structure -
create table test
(month integer,
year integer,
thresholds decimal(18,2)
);
Static insert for simulation -
insert into test(month,year,threshold) values(4,2021,100),(5,2021,98),(6,...
0
votes
1
answer
631
views
SQLParse - issue with the wildcard LIKE condition
I'm focusing on the Where clause of a SQL statement and I'm trying to pull back all the columns used in the Where clause. Below is an example SQL:
sql_2 = """Select
PERS_ID
, STF_NO
, ...
-2
votes
1
answer
802
views
Parse SQL Query string to get a map of values [closed]
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 '...