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: 12 months ago
JSON representation
Printer that prints the results of a query to the database.
- Host: GitHub
- URL: https://github.com/k1low/qp
- Owner: k1LoW
- License: mit
- Created: 2022-03-22T07:13:30.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-23T22:30:54.000Z (about 4 years ago)
- Last Synced: 2025-03-29T05:41:34.601Z (about 1 year ago)
- Topics: database, go, printer, sql
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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 | alice@example.com | 2017-12-05 00:00:00 | |
+----+----------+----------+-------------------+---------------------+---------+
(1 row)
```