Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shomali11/xsql
SQL Query Results Pretty Printing
https://github.com/shomali11/xsql
pretty pretty-print sql sql-format
Last synced: 3 months ago
JSON representation
SQL Query Results Pretty Printing
- Host: GitHub
- URL: https://github.com/shomali11/xsql
- Owner: shomali11
- License: mit
- Created: 2017-10-26T22:55:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-08T14:15:02.000Z (over 5 years ago)
- Last Synced: 2024-10-25T02:46:22.891Z (3 months ago)
- Topics: pretty, pretty-print, sql, sql-format
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 33
- Watchers: 6
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xsql [![Build Status](https://travis-ci.com/shomali11/xsql.svg?branch=master)](https://travis-ci.com/shomali11/xsql) [![Go Report Card](https://goreportcard.com/badge/github.com/shomali11/xsql)](https://goreportcard.com/report/github.com/shomali11/xsql) [![GoDoc](https://godoc.org/github.com/shomali11/xsql?status.svg)](https://godoc.org/github.com/shomali11/xsql) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
SQL Query Results Pretty Printing
## Dependencies
* `util` [github.com/shomali11/util](https://github.com/shomali11/util)
# Examples
## Example 1
```go
package mainimport (
"database/sql"
"fmt"
"github.com/shomali11/xsql"
"log"
)const (
dataSourceFormat = "user=%s password=%s dbname=%s sslmode=disable"
)func main() {
dataSource := fmt.Sprintf(dataSourceFormat, "", "", "")
db, err := sql.Open("", dataSource)
if err != nil {
log.Fatal(err)
}defer db.Close()
rows, err := db.Query("SELECT * FROM test")
if err != nil {
log.Fatal(err)
}results, err := xsql.Pretty(rows)
if err != nil {
log.Fatal(err)
}fmt.Println(results)
}
```Output:
```
id | name | title | created_at | number | decimal | active
-----+----------------+-----------------------+-----------------------------+--------+---------+--------
1 | Raed Shomali | Sr. Software Engineer | 2017-10-24T20:59:43.37154Z | 11 | 789.123 | true
2 | Dwayne Johnson | The Rock | 2017-10-24T21:00:31.530534Z | 1000 | 3.7 | true
300 | Steve Austin | Stone Cold | 2017-10-26T19:42:51.993465Z | 55000 | 55.55 | false
(3 rows)
```