From: Oleg Broytman Date: Wed, 3 Aug 2016 16:05:51 +0000 (+0300) Subject: Parse many queries from command line X-Git-Tag: 0.0.1~43 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=77dbb9d37dfcca2a1287879f40cb781121eaeffb;p=sqlconvert.git Parse many queries from command line --- diff --git a/scripts/print_subtree.py b/scripts/print_subtree.py index f1da6de..8a37d95 100755 --- a/scripts/print_subtree.py +++ b/scripts/print_subtree.py @@ -14,8 +14,8 @@ def test(): "/*! directive*/ INSERT INTO `MyTable` (`Id`, `Name`) " "VALUES (1, 'one')" ): - print("----------") for parsed in parse(query): + print("----------") requote_names(parsed) print_tokens(parsed) print() @@ -24,17 +24,20 @@ def test(): def main(query): - parsed = parse(query)[0] - requote_names(parsed) - print_tokens(parsed) - print() - parsed._pprint_tree() + for parsed in parse(query): + print("----------") + requote_names(parsed) + print_tokens(parsed) + print() + parsed._pprint_tree() + print("----------") if __name__ == '__main__': - if len(sys.argv) != 2: - sys.exit("Usage: %s [-t | sql_query_string]" % sys.argv[0]) + if len(sys.argv) <= 1: + sys.exit("Usage: %s [-t | sql_query_string [; sql_query_string ...]]" % + sys.argv[0]) if sys.argv[1] == '-t': test() else: - query = sys.argv[1] + query = ';'.join(sys.argv[1:]) main(query)