Skip to content

Latest commit

 

History

History

sql-formatter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

sql-formatter

alpine:edge-based dockerization of sql-formatter the util for formatting SQL queries

As the site says:

SQL Formatter is a JavaScript library for pretty-printing SQL queries [...] SQL formatter supports the following dialects:

The source code for this image is hosted on GitHub in the backplane/conex repo.

Usage

Interactive

The following shell function can assist in running this image interactively:

sql_formatter() {
  docker run \
    --rm \
    --interactive \
    --tty \
    --volume "$(pwd):/work" \
    "backplane/sql-formatter" \
    "$@"
}

when run interactively with the -h argument, the container produces the following usage text:

usage: sql-formatter [-h] [-o OUTPUT] [--fix]
                     [-l {bigquery,db2,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sqlite,sql,trino,transactsql,tsql,singlestoredb,snowflake}]
                     [-c CONFIG] [--version]
                     [FILE]

SQL Formatter

positional arguments:
  FILE                  Input SQL file (defaults to stdin)

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        File to write SQL output (defaults to stdout)
  --fix                 Update the file in-place
  -l {bigquery,db2,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sqlite,sql,trino,transactsql,tsql,singlestoredb,snowflake}, --language {bigquery,db2,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sqlite,sql,trino,transactsql,tsql,singlestoredb,snowflake}
                        SQL Formatter dialect (defaults to basic sql)
  -c CONFIG, --config CONFIG
                        Path to config json file (will use default configs if unspecified)
  --version             show program's version number and exit