from cratedb_sqlparse import sqlparse
query = """
SELECT COUNT(*) FOM doc.tbl f WHERE f.id = 1;
INSERT INTO doc.tbl VALUES (1, 23, 4);
"""
t = sqlparse(query)
t1 = t[0]
print(t1.exception.original_query_with_error_marked)
Error message:
SELECT COUNT(*) FOM doc.tbl f WHERE f.id = 1;
^^^
INSERT INTO doc.tbl VALUES (1, 23, 4);
I assume this happens because antlr4 doesn't know that 'FOM' should be a 'FROM' and therefore the error it finds is InputMismatchException[line 2:20 mismatched input 'doc' expecting {<EOF>, ';'}]
Error message:
I assume this happens because antlr4 doesn't know that 'FOM' should be a 'FROM' and therefore the error it finds is
InputMismatchException[line 2:20 mismatched input 'doc' expecting {<EOF>, ';'}]
The offendingToken that antrl4 gives is: