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

17 lines
250 B
Go
Raw Permalink Normal View History

2020-04-09 11:15:34 +00:00
package sqlx
2020-04-08 19:20:23 +00:00
import (
2020-04-09 11:15:34 +00:00
"log"
_ "github.com/jackc/pgx/v5/stdlib"
2020-04-09 11:15:34 +00:00
"github.com/jmoiron/sqlx"
2020-04-08 19:20:23 +00:00
)
2020-04-09 11:15:34 +00:00
func Open() {
db, err := sqlx.Open("pgx", "postgres://pgx_md5:secret@localhost:5432/pgx_test")
if err != nil {
log.Fatal(err)
}
defer db.Close()
2020-04-08 19:20:23 +00:00
}