Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kakilangit/pegi
An sqlx wrapper mainly for PostgreSQL
https://github.com/kakilangit/pegi
go postgresql query-builder sqlx transaction-runner
Last synced: 21 days ago
JSON representation
An sqlx wrapper mainly for PostgreSQL
- Host: GitHub
- URL: https://github.com/kakilangit/pegi
- Owner: kakilangit
- License: mit
- Created: 2022-01-16T09:04:34.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-10T15:39:58.000Z (over 2 years ago)
- Last Synced: 2024-06-21T13:10:29.828Z (5 months ago)
- Topics: go, postgresql, query-builder, sqlx, transaction-runner
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pegi
[![PkgGoDev](https://pkg.go.dev/badge/github.com/kakilangit/pegi)](https://pkg.go.dev/github.com/kakilangit/pegi)
[![Build Status](https://app.travis-ci.com/kakilangit/pegi.svg?branch=main)](https://app.travis-ci.com/github/kakilangit/pegi)A sqlx wrapper mainly for PostgreSQL.
```shell
go get -u -v github.com/kakilangit/pegi
```Example:
```go
package mainimport (
"context"
"database/sql"
"log""github.com/jmoiron/sqlx"
"github.com/kakilangit/pegi"
)func main() {
db := pegi.NewDB(&sqlx.DB{}, &sql.TxOptions{})
if err := db.RunInTransaction(context.Background(), func(ctx context.Context) error {
var id string
if err := db.GetAccess(ctx).Get(&id, "SELECT id FROM users WHERE name = ?", "name"); err != nil {
return err
}_, err := db.QueryBuilder(ctx).Update("users").Set("address", "new address").Where("id = ?", id).Exec()
return err
}); err != nil {
log.Fatal(err)
}
}```