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

16 lines
241 B
Go

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