2 from __future__ import print_function
5 from sqlparse import parse
6 from mysql2sql.print_tokens import print_tokens
7 from mysql2sql.process_tokens import requote_names, find_error, \
12 grouper = StatementGrouper()
14 grouper.process(parse(query)[0])
15 if grouper.statements:
16 for statement in grouper.get_statements():
18 if find_error(statement):
19 print("ERRORS IN QUERY")
20 requote_names(statement)
21 print_tokens(statement)
23 statement._pprint_tree()
25 tokens = grouper.close()
33 "SELECT * FROM `mytable`; -- line-comment",
34 "INSERT into /* inline comment */ mytable VALUES (1, 'one');",
35 "/*! directive*/ INSERT INTO `MyTable` (`Id`, `Name`) "
40 if __name__ == '__main__':
41 if len(sys.argv) <= 1:
42 sys.exit("Usage: %s [-t | sql_query_string [; sql_query_string ...]]" %
44 if sys.argv[1] == '-t':
47 queries = sys.argv[1:]