Python Sqlparse: How to get the boolean status if sql query is not in correct format

92 Views Asked by At

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 status.

I did not see any function in sqlparse docuementation for the same.

Example of my use case

This should return true:

select 
    count(users), 
    department 
from 
   usertable
group by department

This should return false:

select 
    count(users), 
    department,
    location 
from 
   usertable
group by department
0

There are 0 best solutions below