Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/k1low/qp

Printer that prints the results of a query to the database.
https://github.com/k1low/qp

database go printer sql

Last synced: about 1 month ago
JSON representation

Printer that prints the results of a query to the database.

Awesome Lists containing this project

README

        

# qp

Printer that prints the results of a query to the database.

## Usage

``` go
package main

import (
"database/sql"
"log"

"github.com/k1LoW/qp"
_ "github.com/mattn/go-sqlite3"
)

func main() {
db, err := sql.Open("sqlite3", "path/to/db")
if err != nil {
log.Fatal(err)
}
defer db.Close()

qp.Print(db, "SELECT * FROM users WHERE username = 'alice'")
}
```

``` console
$ go run main.go
+----+----------+----------+-------------------+---------------------+---------+
| id | username | password | email | created | updated |
+----+----------+----------+-------------------+---------------------+---------+
| 1 | alice | passw0rd | [email protected] | 2017-12-05 00:00:00 | |
+----+----------+----------+-------------------+---------------------+---------+
(1 row)
```