from sqlparse.sql import TokenList
-from sqlparse.tokens import Name
+from sqlparse.tokens import Name, Error
def requote_names(token_list):
token.normalized = token.value = value
else:
token.normalized = token.value = '"%s"' % value
+
+
+def find_error(token_list):
+ """Find an error"""
+ for token in token_list:
+ if isinstance(token, TokenList):
+ if find_error(token):
+ return True
+ elif token.ttype is Error:
+ return True
+ return False
import sys
from sqlparse import parse
-from mysql2sql.process_tokens import requote_names
from mysql2sql.print_tokens import print_tokens
+from mysql2sql.process_tokens import requote_names, find_error
def test():
):
for parsed in parse(query):
print("----------")
+ if find_error(parsed):
+ print("ERRORS IN QUERY")
requote_names(parsed)
print_tokens(parsed)
print()
for query in queries:
for parsed in parse(query):
print("----------")
+ if find_error(parsed):
+ print("ERRORS IN QUERY")
requote_names(parsed)
print_tokens(parsed)
print()