Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swithek/dotsqlx
Dotsql wrapper allowing seemless work with jmoiron/sqlx
https://github.com/swithek/dotsqlx
go golang sql
Last synced: 6 days ago
JSON representation
Dotsql wrapper allowing seemless work with jmoiron/sqlx
- Host: GitHub
- URL: https://github.com/swithek/dotsqlx
- Owner: swithek
- License: gpl-2.0
- Created: 2020-03-20T16:47:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-21T16:25:42.000Z (about 1 year ago)
- Last Synced: 2024-06-19T04:20:54.202Z (5 months ago)
- Topics: go, golang, sql
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 17
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotsqlx
[![GoDoc](https://godoc.org/github.com/swithek/dotsqlx?status.png)](https://godoc.org/github.com/swithek/dotsqlx)
[![Build status](https://travis-ci.org/swithek/dotsqlx.svg?branch=master)](https://travis-ci.org/swithek/dotsqlx)
[![Go Report Card](https://goreportcard.com/badge/github.com/swithek/dotsqlx)](https://goreportcard.com/report/github.com/swithek/dotsqlx)[Dotsql](https://github.com/qustavo/dotsql) wrapper allowing seemless work with [jmoiron/sqlx](https://github.com/jmoiron/sqlx)
## Installation
```
go get github.com/swithek/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
}```