Begin migration to sqlc
This commit is contained in:
17
postgres/conn.go
Normal file
17
postgres/conn.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user