shad-go/lectures/07-sql/sqlx/open.go

16 lines
250 B
Go

package sqlx
import (
"log"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/jmoiron/sqlx"
)
func Open() {
db, err := sqlx.Open("pgx", "postgres://pgx_md5:secret@localhost:5432/pgx_test")
if err != nil {
log.Fatal(err)
}
defer db.Close()
}