Installing Atom Editor SQLformat on a Mac for Beautify Package

931 views Asked by At

I have the Atom editor installed on my Mac, with the Beautify Package. Works great for HTML,etc, but when I try to Beautify SQL it says that it needs SQLFormat, which is not installed by default. When I follow the github link it shows that SQLFormat is Python, install instructions are downalod zip and 'pip install sqlparse'. Do I need to install Python to load sqlparse? Anyone have some simple instructions on how to load on a mac?

1

There are 1 answers

0
gajanan ganji On BEST ANSWER

first install sqlparse with pip ( to do this you need to have python)

pip install sqlparse

Once it's installed note down the python version with which its installed. e.g. in my case it was python3.7 / python3

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: sqlparse in ./Library/Python/3.7/lib/python/site-packages (0.4.2)

make sure /usr/local/bin/ is on your PATH variable by running echo $PATH if not add it your PATH variable.

then create a file sqlformat under /usr/local/bin/ (i.e. /usr/local/bin/sqlformat) using any editor of your choice and paste below snippet, make sure to use correct version of python and save the file

#!/bin/bash
FLAGS="$f $p $@"

exec python3 -m sqlparse $FLAGS

finally do change the file permission by chmod 755 /usr/local/bin/sqlformat