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

https://github.com/alexandermac/sqlx-queryable

Provides the Queryable interface for identical sqlx.DB and sqlx.Tx methods.
https://github.com/alexandermac/sqlx-queryable

Last synced: 5 months ago
JSON representation

Provides the Queryable interface for identical sqlx.DB and sqlx.Tx methods.

Awesome Lists containing this project

README

          


sqlx-queryable


Provides an interface for identical sqlx.DB and sqlx.Tx methods.



Build Status
Go Report Card
Go Docs
License
GitHub tag

sqlx-queryable provides the `Queryable` interface which wraps identical `sqlx.DB` and `sqlx.Tx` methods. The interface can be used when a function performs a database query directly or under a transaction.
Requires Golang v1.18 or greater.

### Install
```sh
go get github.com/alexandermac/sqlx-queryable
```

### Usage
```go
import queryable "github.com/alexandermac/sqlx-queryable"

// `q` can be sqlx.DB or sqlx.Tx
func getRecords(q Queryable) ([]Record, error) {
var records []Record
err := q.Select(&records, "SELECT * FROM records")
if err != nil {
panic(err)
}

return records, nil
}
```

### License
Licensed under the MIT license.

### Author
Alexander Mac