I would like to have an option to customize the SQL formatter. Different people have different styles formatter an SQL query and I would like it very much if DBeaver could automatically format SQL statements the way I want them.
An easy way would be to add an option where one can set a program path. This program takes the SQL from STDIN and outputs it formatted on STDOUT. So everybody can use or write his own formatter script.
+1 for this
Makes sense. And not hard to do. Will try it after 3.6.2.
Can you name some external formatting tools I can test with?
+1
Also does it make sense to "lock" (prevent new posts & maybe new comments) the feature request forum. There is a similar request there http://dbeaver.jkiss.org/forum/viewtopic.php?f=3&t=1343
I know you've posted please post all feature requests on github but users are still posting over there and it seems less than ideal to have to keep track of 2 different areas.
Hey Serge,
The above commit appears to be included in 3.6.2. Is this feature live / can you post an example of how to use it?
The feature isn't yet ready. Maybe in 3.6.3, but not for sure.
Thanks for the update.
Also based on my reading of @choclin 's suggestion it sounds like way the feature was requested any programming language could be used to format the string. Is this correct? (I plan on using this feature with a python script).
Yes, my idea was that you can use any external executable, so everybody could write or use his own formatter. I don't have such a script ready to use here. A simple way would be to use a simple Python script using the sqlparse module. To me, the options of that module are not enough, but it would be enough to get started.
More precise:
Write a Perl script like this:
#!/usr/bin/perl
use strict;
use warnings;
use SQL::Beautify;
my $sql_query = <STDIN>;
my $sql = SQL::Beautify->new();
$sql->query($sql_query);
print $sql->beautify;
Now you can call it and send your SQL to STDIN, you will get out the formatted statement.
Or with a Perl one-liner:
perl -MSQL::Beautify -e 'print SQL::Beautify->new(query => join "" => <STDIN>)->beautify'
For example, on a shell:
echo "SELECT * FROM sklhfkajshf  ✓  08:45:41
WHERE cxc=98" | perl -MSQL::Beautify -e 'print SQL::Beautify->new(query => join "" => <STDIN>)->beautify'
...outputs:
SELECT
*
FROM
sklhfkajshf
WHERE
cxc = 98
Yes, I got the idea.
Will try to add external formatter support in one of the next versions.
In SQLyog, I can start writing a SQL statement and it automatically converts keywords to uppercase within the editior. Is there already an option to do the following?
Not yet, you could create a feature request. It is possible to make such runtime conversions using Eclipse text editor framework.
Well, first version is ready (wait for 3.6.3 or build from sources).

Uhm... one thing about it:
It would be great to add an option to only format the current selection? (low prio, of course)
This feature is already there - just select a query and press ctrl+alt+f.
Thank you for your fast reaction! I tried to build it from sources (via Docker's maven image) and got the following error when running mvn install:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:24 min
[INFO] Finished at: 2016-03-21T08:22:19+00:00
[INFO] Final Memory: 204M/1495M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.23.1:compile (default-compile) on project org.jkiss.dbeaver.core: Compilation failure: Compilation failure:
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageSQLFormat.java:[39]
[ERROR] import org.jkiss.dbeaver.model.sql.format.external.SQLExternalFormatter;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'SQLExternalFormatter' is not API (restriction on classpath entry '/usr/src/app/plugins/org.jkiss.dbeaver.model/target/classes')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageSQLFormat.java:[104]
[ERROR] formatterSelector.add(SQLExternalFormatter.FORMATTER_ID);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'SQLExternalFormatter' is not API (restriction on classpath entry '/usr/src/app/plugins/org.jkiss.dbeaver.model/target/classes')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/preferences/PrefPageSQLFormat.java:[104]
[ERROR] formatterSelector.add(SQLExternalFormatter.FORMATTER_ID);
[ERROR] ^^^^^^^^^^^^
[ERROR] Access restriction: The field 'SQLExternalFormatter.FORMATTER_ID' is not API (restriction on classpath entry '/usr/src/app/plugins/org.jkiss.dbeaver.model/target/classes')
[ERROR] 3 problems (3 errors)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :org.jkiss.dbeaver.core
Fixed
Now I get even more errors, but others:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:28 min
[INFO] Finished at: 2016-03-21T09:12:18+00:00
[INFO] Final Memory: 190M/1132M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.23.1:compile (default-compile) on project org.jkiss.dbeaver.core.application: Compilation failure: Compilation failure:
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[21]
[ERROR] import org.eclipse.e4.ui.css.core.dom.ExtendedDocumentCSS;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'ExtendedDocumentCSS' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[22]
[ERROR] import org.eclipse.e4.ui.css.core.engine.CSSEngine;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'CSSEngine' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[23]
[ERROR] import org.eclipse.e4.ui.css.swt.dom.WidgetElement;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'WidgetElement' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.swt/0.12.0.v20150511-1003/org.eclipse.e4.ui.css.swt-0.12.0.v20150511-1003.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[49]
[ERROR] CSSEngine engine = WidgetElement.getEngine(display);
[ERROR] ^^^^^^^^^
[ERROR] Access restriction: The type 'CSSEngine' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[49]
[ERROR] CSSEngine engine = WidgetElement.getEngine(display);
[ERROR] ^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'WidgetElement' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.swt/0.12.0.v20150511-1003/org.eclipse.e4.ui.css.swt-0.12.0.v20150511-1003.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[49]
[ERROR] CSSEngine engine = WidgetElement.getEngine(display);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'WidgetElement.getEngine(Display)' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.swt/0.12.0.v20150511-1003/org.eclipse.e4.ui.css.swt-0.12.0.v20150511-1003.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[54]
[ERROR] ExtendedDocumentCSS doc = (ExtendedDocumentCSS) engine.getDocumentCSS();
[ERROR] ^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'ExtendedDocumentCSS' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[54]
[ERROR] ExtendedDocumentCSS doc = (ExtendedDocumentCSS) engine.getDocumentCSS();
[ERROR] ^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'ExtendedDocumentCSS' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[54]
[ERROR] ExtendedDocumentCSS doc = (ExtendedDocumentCSS) engine.getDocumentCSS();
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'CSSEngine.getDocumentCSS()' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[63]
[ERROR] sheets.add(engine.parseStyleSheet(reader));
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'CSSEngine.parseStyleSheet(Reader)' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[64]
[ERROR] doc.removeAllStyleSheets();
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'ExtendedDocumentCSS.removeAllStyleSheets()' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[66]
[ERROR] doc.addStyleSheet(sheet);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'ExtendedDocumentCSS.addStyleSheet(StyleSheet)' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationCSSManager.java:[68]
[ERROR] engine.reapply();
[ERROR] ^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'CSSEngine.reapply()' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.css.core/0.11.0.v20150511-1937/org.eclipse.e4.ui.css.core-0.11.0.v20150511-1937.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationTabRenderer.java:[21]
[ERROR] import org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'CTabRendering' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.workbench.renderers.swt/0.13.0.v20150901-1347/org.eclipse.e4.ui.workbench.renderers.swt-0.13.0.v20150901-1347.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationTabRenderer.java:[31]
[ERROR] public class ApplicationTabRenderer extends CTabRendering {
[ERROR] ^^^^^^^^^^^^^
[ERROR] Access restriction: The type 'CTabRendering' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.workbench.renderers.swt/0.13.0.v20150901-1347/org.eclipse.e4.ui.workbench.renderers.swt-0.13.0.v20150901-1347.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationTabRenderer.java:[35]
[ERROR] super(parent);
[ERROR] ^^^^^^^^^^^^^^
[ERROR] Access restriction: The constructor 'CTabRendering(CTabFolder)' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.workbench.renderers.swt/0.13.0.v20150901-1347/org.eclipse.e4.ui.workbench.renderers.swt-0.13.0.v20150901-1347.jar')
[ERROR] /usr/src/app/plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/ApplicationTabRenderer.java:[40]
[ERROR] super.draw(part, state, bounds, gc);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The method 'CTabRendering.draw(int, int, Rectangle, GC)' is not API (restriction on classpath entry '/root/.m2/repository/p2/osgi/bundle/org.eclipse.e4.ui.workbench.renderers.swt/0.13.0.v20150901-1347/org.eclipse.e4.ui.workbench.renderers.swt-0.13.0.v20150901-1347.jar')
[ERROR] 17 problems (17 errors)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :org.jkiss.dbeaver.core.application
Building the master branch works well.
Yeah, fixed that one too.
Honestly I'm making cli build not very often, usually only before new version releases.
Master branch is always stable (it is a previous version actually).
Now it was built successfully :-)
I know about master, I only mentioned it to state that it is probably not a general problem in my environment.
It does not really work here. I filled the settings like that:

I also tried a very simple command like perl -e 'print uc <STDIN>' which would translate every character to its uppercase variant.
I both cases I get a org.eclipse.jface.text.BadLocationException when typing space bar after a keyword. I also get:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at org.jkiss.dbeaver.model.sql.format.tokenized.SQLTokenizedFormatter.insertReturnAndIndent(SQLTokenizedFormatter.java:362)
at org.jkiss.dbeaver.model.sql.format.tokenized.SQLTokenizedFormatter.format(SQLTokenizedFormatter.java:173)
at org.jkiss.dbeaver.model.sql.format.tokenized.SQLTokenizedFormatter.format(SQLTokenizedFormatter.java:63)
at org.jkiss.dbeaver.ui.editors.sql.syntax.SQLFormattingStrategy.format(SQLFormattingStrategy.java:60)
at org.eclipse.jface.text.formatter.ContentFormatter.format(ContentFormatter.java:518)
at org.eclipse.jface.text.formatter.ContentFormatter.formatRegion(ContentFormatter.java:429)
Sometimes it seems to be formatted with the internal formatter, even if the external one is activated.
And what about the SQL preview in the formatter settings dialog? Should it preset the SQL statement formatted with the selected formatter immediately?
Some case conversions issues. Fixed.
But I wasn't able to reproduce that exception. Looks weird.
SQL preview updates on "Apply" button.
Is there any place where I can find log information about the execution of the external command? So I could try to find the issue.
It still doesn't work with recent fixes?
If any problem happens with external tool you should see error dialog.
Now it works! I had to create a script to do the work.
The one-liner
perl -MSQL::Beautify -e 'print SQL::Beautify->new(uc_keywords => 1, query => join "" => <STDIN>)->beautify'
used as
echo "SELECT * FROM table" | perl -MSQL::Beautify -e 'print SQL::Beautify->new(uc_keywords => 1, query => join "" => <STDIN>)->beautify'
works on the shell, but silently outputs nothing within DBeaver. Maybe there is a problem with escaping the quotation marks ...?
Turn off "Use temp file" option. It makes sense only if formatter program can't work with stdin.
By default SQL query will be sent into external program's stdin.
Maybe this option is a bit confusing..
This option is deactivated:

Hmm. Work ok on windows.
Will try it on Ubuntu later today.
Thank you.
Something is wrong with output reading..
Try to put entire command in a shell script and execute it as "sh yourscript.sh".
This works (similar to what I described above). It is okay for me, but it probably should be noted that there may be a problem with this type of commands.
Try it now
It works, thank you!
I'm struggling to get this working what am I doing wrong?
tried
python path\\script.py $(file)
python path\\script.py <STDIN>
for reference my python script im testing is as follows
import sys
message = '# called ' + sys.argv[0] + '\n'
message += sys.argv[1]
print(message)
basically i just want it to return the exact sample sql unformatted with an additional line at the top with the name of the script. instead i'm just getting

-- Edit nvm i got it
python path\\script.py
import sys
message = '--called ' + sys.argv[0] + '\n'
for line in sys.stdin:
message += line.rstrip() + '\n'
print(message)
Hello, where meeting the psti.exe that Serge is using?
Its is just some PLSQL formatter I found on the Internet.
Thanks for the answer.
I can not find it psti.exe :(
U could send me? or send me other?
Hi there,
I believe that can be this one here:
It's a SQL formatter for pl/sql for windows or Linux trough wine.
Probably you have to install it to get that exe file.
On Jul 21, 2016 5:36 PM, "giquieu" [email protected] wrote:
Thanks for the answer.
I can not find it psti.exe :(
U could send me? or send me other?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/serge-rider/dbeaver/issues/267#issuecomment-234376086,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAm7RzgwZ3GpgUw92Bwz5UlEGjdZRX9gks5qX9hRgaJpZM4HqHaJ
.
I use the below tool. It is really great.
http://www.architectshack.com/PoorMansTSqlFormatter.ashx
Tried to set it up by
This formatter is very slow (it takes more than 1 seconds to format a tiny SQL).
So you need to increase timeout in external formatter preferences (at least to 2 seconds).
Hey, Thanks. Yes. I figured. It works fine in SSMS and Visual Studio. But command line tool just takes too long.
One quick question. When using external formatter with file, passes file as input. But does it expects output at STDOUT or file? Is there a way to specify it? I learned from above that ${file} can be input file. But how to tell DBeaver where to look for output?
For now DBeaver always gets output from STDOUT. There is not way to redefine that. Although it is possible to use a batch script which will pipe output from file to STDOUT.
Hello, I wrote a commercial SQL Formatter called SQLinForm and it can be included as external formatter into DBeaver. There are also free versions like the free Notepad++ plugin.
If you think that this message is not OK, as it links to a commercial product then please feel free to remove it.
Regards
Anyone got this working with Poor Mans SQL Formatter??
http://architectshack.com/poormanstsqlformatter.ashx
@jimpriest In case you didn't get this solved yet, you should be able to download the command line tool (currently 1.6.10) for Poor Mans SQL Formatter and just link to the executable in the Command Line textbox. The following should work fine and works fine for me.

@tbcrawford Tried that but doesn't work for me for some reason. I'm on Windows 10, DBeaver 5.1.2.
I downloaded SQL Formatter 1.6.10, I have to add an extra slash or DBeaver complains but I get no formatting: C:\tools\SqlFormatter\SqlFormatter.exe
If I don't double slash I get:
_Cannot run program "C:tools\SqlFormatter\SqlFormatter.exe": CreateProcess error=2, The system cannot find the file specified_
I hit Format and nothing happens, no error, no formatting.
So with confirmation this works I decided to reinstall DBeaver - I selected to 'reset settings'
I still have to use a double slash in the path but now the formatter actually does something :)
It works!
Hi,
I cannot make this Poor formatter to work. Tried the solution suggested, but when a applying formatting, nothing happens.
Here is my settings:

Can someone help me to set it up?
Thanks
I have:
C:\path\sqlformatter\sqlformatter.exe /sac
And "use temp file" is unchecked.
Not sure what the /sac flags do - I can't remember. Could probably run the command with a --help or /? and see what the flags were.
Hello,
I am trying to add an external formatter from my Mac and use that as a template for formatting SQL.
On the command line I have the path to my file: /Users/username/format.sql. The file has execution rights and the below content:
SELECT
I select the "Use temp file checkbox" but once I click "Apply" I get the following message in the preview section.
/Users/username/format.sql: line 1: SELECT: command not found
/Users/username/format.sql: line 2: 100: command not found
Can anyone, please help and let me know how should the external file (format.sql) look like?
Thanks,
Paul M.
Hi Paul,
a SQL file is not an executable file. You have to provide a shell script or an executable binary that takes SQL as input and outputs formatted SQL.
Thanks for your answer Dominic. I'll give it a try using your suggestion.
I am trying to use with the Poor Man's formatter on a mac. I.e. using the npm packages from here.
Verified working from the terminal (echo "select" | sqlformat --> SELECT)
It seems to be an issue with the PATH being different:
In the _Command line:_ field, adding just sqlformat results in an error "No such file..."
Adding the full path (/usr/local/bin/sqlformat) results in env: node: No such file or directory, which (from googling) might be due to _node_ not being found.
Have anyone had success setting up poorman's formatter on mac?
@adamal I've configured it by passing the full paths of node and sqlformat in the command line

You should be able to see the absolute paths by running which node and which sqlformat, then put them together one after the other in the command line
This works great! Thanks for the screenshot!
Most helpful comment
@adamal I've configured it by passing the full paths of node and sqlformat in the command line

You should be able to see the absolute paths by running
which nodeandwhich sqlformat, then put them together one after the other in the command line