As part of a hubby project I am working on, I need to be able to take SQL strings supplied by users, and then run it.
But before running it, i will like to do some manipulations to the SQL. For example, I may want to have a copy of the SQL that does a COUNT query version of the original query...I might want to insert LIMIT clauses if not provided, or I might want to manipulate the columns specified, rename or even insert columns.
Now the question is: I am not sure how to go able this and what sort of tools to even look for. I think in essence I want to be able to manipulate the SQL not as a string but as a data structure I can manipulate.
Using regex and string manipulation does not sound like the right tool for the job. What will you say is the right way to go about this?