Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/k1low/qp
- Owner: k1LoW
- License: mit
- Created: 2022-03-22T07:13:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-23T22:30:54.000Z (over 2 years ago)
- Last Synced: 2024-10-06T04:16:57.888Z (about 1 month 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 mainimport (
"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)
```