Files
budgeteer/postgres/conn.go
2021-11-08 21:32:30 +00:00

18 lines
382 B
Go

package postgres
import (
"context"
"fmt"
"github.com/jackc/pgx/v4"
)
// Connect to a database
func Connect(server string, user string, password string, database string) (*Queries, error) {
conn, err := pgx.Connect(context.Background(), fmt.Sprintf("postgresql://%s:%s@%s/%s", user, password, server, database))
if err != nil {
return nil, err
}
return New(conn), nil
}