Begin migration to sqlc
This commit is contained in:
@ -1,14 +1,30 @@
|
||||
package postgres
|
||||
|
||||
import "gopkg.in/pg.v5"
|
||||
|
||||
// Connect to a database
|
||||
func Connect(server string, user string, password string, database string) *pg.DB {
|
||||
db := pg.Connect(&pg.Options{
|
||||
User: user,
|
||||
Password: password,
|
||||
Addr: server,
|
||||
Database: database,
|
||||
})
|
||||
return db
|
||||
}
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v4"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user