Ejemplo n.º 1
0
// MustConnectTest is a helper function that creates a
// new database connection using environment variables.
func MustConnectTest(opts ...dbr.ConnectionOption) *dbr.Connection {
	dsn, err := GetDSNTest()
	if err != nil {
		panic(err)
	}
	return dbr.MustConnectAndVerify(dbr.SetDSN(dsn)).ApplyOpts(opts...)
}
Ejemplo n.º 2
0
// Connect creates a new database connection from a DSN stored in an
// environment variable.
func Connect(opts ...dbr.ConnectionOption) (*dbr.Connection, error) {
	dsn, err := GetDSN()
	if err != nil {
		return nil, errgo.Mask(err)
	}
	c, err := dbr.NewConnection(dbr.SetDSN(dsn))
	return c.ApplyOpts(opts...), err
}