Helper script that allows setting DBeaver with any Sqlfluff formatting set up.
- Checkout this repo or save the bash script
sqlfluff-for-dbeaver.shin your local environment. - Make sure the script is executable,
chmod +x sqlfluff-for-dbeaver.sh.
If you are using a python venv, you can typically activate it an run pip show sqlfluff to get the site-packages location, which will look like this:
/Users/foo/.pyenv/versions/3.12.11/envs/my-project-venv/lib/python3.12/site-packages.- You can then, simply adapt the path to get the executable:
/Users/foo/.pyenv/versions/3.12.11/envs/my-project-venv/bin/sqlfluff
- In DBeaver, open
Preferences->Editors->SQL Editor->Formatting.- Select
External Formatterunder "Formatter", the "Format active query only" checkbox should be checked. - The "Use temp file" checkbox should be checked.
- On the "Command line" input field, enter the following command:
Users/bar/sqlfluff-for-dbeaver.sh ${file} /Users/foo/my-project/.sqlfluff /Users/foo/.pyenv/versions/3.12.11/envs/my-project-venv/bin/sqlfluf - Select