Created
October 24, 2016 10:29
-
-
Save wings27/abb8f6679ddb7b2323cc4dd3f891fc19 to your computer and use it in GitHub Desktop.
filter lines starting with SHOW and SELECT from a sql file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def main(): | |
try: | |
sql_file = sys.argv[1] | |
with open(sql_file, 'r') as f: | |
lines = f.readlines() | |
filtered_lines = filter(lambda l: | |
not l.startswith('/*') | |
and not l.startswith('SHOW') | |
and not l.startswith('SELECT') | |
, lines) | |
for line in filtered_lines: | |
print(line) | |
except IndexError: | |
print('file argument is required.') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment