Skip to content

dakiva/dbx

Repository files navigation

dbx

A library that provides database extensions for Go. This library requires sqlx, but is compatible with both sql and sqlx.

wercker status

Overview

Installation

Make sure you have a working Go environment. The core library has an external dependency on sqlx. To run the unit tests, however, the testify library is required.

To install, run:

go get github.com/dakiva/dbx

Tests

To run the tests, you'll need to connect to a Postgres database:

POSTGRES_DSN="name= dbname= host= port= sslmode=" go test

The pq Postgres driver and Testify are also required.

Getting Started

This library has support for externalizing queries into JSON files.

const (
      QueryA QueryIdentifier = "QueryA"
      ...
)

queryMap := LoadNamedQueries("path/to/querfile.json", "path/to/queryfile2.json")
db *DB = ...
db.Exec(queryMap.Q(QueryA), ...)

Additionally, the schema_support file contains useful Postgres specific functions for managing schemas.

About

This library is written by Daniel Akiva (dakiva) and is licensed under the apache-2.0 license. Pull requests are welcome.

About

Database Extensions for Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published