Begin migration to sqlc

This commit is contained in:
2021-11-08 21:32:30 +00:00
parent f019c47d21
commit cf1bc70103
17 changed files with 427 additions and 72 deletions

17
postgres/conn.go Normal file
View File

@ -0,0 +1,17 @@
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
}