https://github.com/jellydator/dotsqlx
Dotsql wrapper allowing seemless work with jmoiron/sqlx
https://github.com/jellydator/dotsqlx
go golang sql
Last synced: 5 months ago
JSON representation
Dotsql wrapper allowing seemless work with jmoiron/sqlx
- Host: GitHub
- URL: https://github.com/jellydator/dotsqlx
- Owner: jellydator
- License: gpl-2.0
- Created: 2020-03-20T16:47:04.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-20T17:14:03.000Z (about 1 year ago)
- Last Synced: 2025-04-12T18:04:22.693Z (12 months ago)
- Topics: go, golang, sql
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 18
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotsqlx
[](https://godoc.org/github.com/jellydator/dotsqlx)
[](https://travis-ci.org/jellydator/dotsqlx)
[](https://goreportcard.com/report/github.com/jellydator/dotsqlx)
[Dotsql](https://github.com/qustavo/dotsql) wrapper allowing seemless work with [jmoiron/sqlx](https://github.com/jmoiron/sqlx)
## Installation
```
go get github.com/jellydator/dotsqlx
```
## Usage
```go
// connect to db and obtain a new sqlx db instance.
dbx, err := sqlx.Connect("postgres", "user=foo dbname=bar sslmode=disable")
if err != nil {
// handle error
}
// load your queries and obtain a new dotsql instance.
dot, err := dotsql.LoadFromFile("./queries.sql")
if err != nil {
// handle error
}
// wrap dotsql's instance, extend its logic and allow sqlx support.
dotx := dotsqlx.Wrap(dot)
// execute named dotsql queries in sqlx methods.
var users []Users
if err = dotx.Select(dbx, &users, "select_users"); err != nil {
// handle error
}
// you can use dotsql's methods as well.
res, err := dotx.Exec(dbx, "insert_user")
if err != nil {
// handle error
}
```