Lexing partial SQL in C#

Posted by Chris T on Stack Overflow See other posts from Stack Overflow or by Chris T
Published on 2010-05-30T17:58:02Z Indexed on 2010/05/30 18:02 UTC
Read the original article Hit count: 307

Filed under:
|
|
|
|

I'd need to parse partial SQL queries (it's for a SQL injection auditing tool). For example

'1' AND 1=1--

Should break down into tokens like

[0] => [SQL_STRING, '1']
[1] => [SQL_AND]
[2] => [SQL_INT, 1]
[3] => [SQL_AND]
[4] => [SQL_INT, 1]
[5] => [SQL_COMMENT]
[6] => [SQL_QUERY_END]

Are their any at least lexers for SQL that I base mine off of or any good tools like bison for C# (though I'd rather not write my own grammar as I need to support most if not all the grammar of MySQL 5)

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql