Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/tendant/dbpro

dbpro is a library which provides a set of utility function to simplify the task of generating data in database tables.
https://github.com/tendant/dbpro

Last synced: about 1 month ago
JSON representation

dbpro is a library which provides a set of utility function to simplify the task of generating data in database tables.

Awesome Lists containing this project

README

        

# dbpro
dbpro is a library which provides a set of utility function to simplify the task of generating data in database tables.

## install

go get github.com/tendant/dbpro

## usage

```go
type Person struct {
FirstName string
LastName string
Email string
}

person := Person{
FirstName: "test first name"
LastName: "test last name"
Email: "[email protected]"
}

// query, err := dbpro.GenInsertQuery("postgres", "person"", person)

// vals, err := dbpro.GenInsertValues(person)

// rows, err := db.NamedQuery(stmt, vals)

db, err := sqlx.Connect("postgres", "user=foo dbname=bar sslmode=disable")
if err != nil {
log.Fatalln(err)
}

id, err := dbpro.InsertRow(db, "person", person)
```