Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackc/sqlfmt
SQL Formatter
https://github.com/jackc/sqlfmt
Last synced: 3 months ago
JSON representation
SQL Formatter
- Host: GitHub
- URL: https://github.com/jackc/sqlfmt
- Owner: jackc
- License: apache-2.0
- Archived: true
- Created: 2015-06-13T17:31:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-12-21T21:12:51.000Z (almost 5 years ago)
- Last Synced: 2024-07-18T01:16:34.224Z (4 months ago)
- Language: Yacc
- Size: 1.55 MB
- Stars: 338
- Watchers: 10
- Forks: 23
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sqlfmt
## Installation
```sh
$ 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:
```sh
$ 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:
```sh
$ echo "select * from users" | sqlfmt
select
*
from
users
``````sh
$ 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](./testdata) for more examples.