1

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 values https://github.com/JSQLParser/JSqlParser/issues/167 https://github.com/JSQLParser/JSqlParser/issues/166

So I am looking for open source alternative which can help me with the task

Presto-parser I tried was not able to parse Update queries

If anyone else is aware of any other reliable SQL Parsing library please let me know

2 Answers 2

1

Regarding JSqlParser:

Issue 166 already fixed.

The escaping of single quotes is not supported, but using double single quotes is. Therefore someone could replace all \' using '' before parsing.

EDIT: Issue 167 fixed within actual Snapshot 0.9.5 of JSqlParser.

Sign up to request clarification or add additional context in comments.

Comments

1

One year ago i search for the same thing but finally i use another approach. Those were the projects that i found to parse sql.

  • ANTLR. Is commonly used generic parser. It's a kind of parser generator. From a set of rules it writes the java code. There are rules for a lot of thins like spanish, java or sql.

  • JParsec. Seems similar to the previous one. Seems that already exists SQL rules, but does not seem easy to use.

  • ZQL. Uses JavaCC to auto-generate Java code that parses the SQL. I test this one but i can not get it working as i want. And i think that the project is discontinued.

  • sql-parser. It looks nice, but when i tested it i can not get it working. The link seems to not work, but i think that this is a fork of the original project.

  • jOOQ is a great library for those that don't need or like an ORM and also has a parser.

1 Comment

Thanks @LukasEder I add it. But take into account that this post was written in 2015, and I don't review the topic since then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.