Skip to content

Dotsql wrapper allowing seemless work with jmoiron/sqlx

License

Notifications You must be signed in to change notification settings

swithek/dotsqlx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotsqlx

GoDoc Build status Go Report Card

Dotsql wrapper allowing seemless work with jmoiron/sqlx

Installation

go get github.com/swithek/dotsqlx

Usage

// 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
}

About

Dotsql wrapper allowing seemless work with jmoiron/sqlx

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages