Skip to content

ccoveille-forks/jackc-sqlfmt

 
 

Repository files navigation

sqlfmt

Installation

$ go get github.com/jackc/sqlfmt/...
$ which sqlfmt
$GOPATH/bin/sqlfmt

Usage

  • You can either:

    • Provide the path to one or more SQL files as command line arguments:

      $ sqlfmt testdata/select_where.input.sql
      select
        foo,
        bar
      from
        baz
      where
        foo > 5
        and bar < 2
    • Or, directly provide the SQL string via stdin:

      $ echo "select * from users" | sqlfmt
      select
        *
      from
        users
      $ sqlfmt < testdata/like.input.sql
      select
        foo,
        bar
      from
        baz
      where
        foo like 'abd%'
        or foo like 'ada%' escape '!'
        or foo not like 'abd%'
        or foo not like 'ada%' escape '!'
        or foo ilike 'efg%'
        or foo ilike 'ada%' escape '!'
        or foo not ilike 'efg%'
        or foo not ilike 'ada%' escape '!'
  • View testdata for more examples.

Packages

No packages published

Languages

  • Go 79.1%
  • Yacc 20.9%