Skip to content

Instantly share code, notes, and snippets.

@whyvez
Created May 3, 2014 14:44
Show Gist options
  • Select an option

  • Save whyvez/e4ecb6dfebbeb435b9ff to your computer and use it in GitHub Desktop.

Select an option

Save whyvez/e4ecb6dfebbeb435b9ff to your computer and use it in GitHub Desktop.
pipeable util to format sql scripts
#!/usr/local/bin/python
import sys
import sqlparse
# usage cat test.sql | ./format_sql.py > test2.sql
def main(argv):
sql = sys.stdin.read().replace('\n', '')
print sqlparse.format(sql, reindent=True, keyword_case='upper')
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment