X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=scripts%2Fprint_subtree.py;h=8a37d957f08b69bc2c0a5629a7e20822e06ddcef;hb=77dbb9d37dfcca2a1287879f40cb781121eaeffb;hp=f1da6de13caf4f515be588764e96e715124479aa;hpb=51018ab80b945523dc678b80d4dd28191b3fd50c;p=sqlconvert.git 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)