3 from sqlparse.sql import TokenList
6 def print_subtree(token_list, ident=0):
7 for token in token_list:
8 print " "*ident, repr(token)
9 if isinstance(token, TokenList):
10 print_subtree(token, ident+4)
13 def print_tokens(token_list, level=0):
14 for token in token_list:
15 if not isinstance(token, TokenList):
16 sys.stdout.write(token.normalized)
17 if isinstance(token, TokenList):
18 print_tokens(token, level+1)