sql driver to pgx driver
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
todohandler "gitea.michaelthomson.dev/mthomson/habits/internal/todo/handler"
|
||||
todorepository "gitea.michaelthomson.dev/mthomson/habits/internal/todo/repository/postgres"
|
||||
todoservice "gitea.michaelthomson.dev/mthomson/habits/internal/todo/service"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -30,7 +30,8 @@ func main() {
|
||||
|
||||
// create db pool
|
||||
postgresUrl := "postgres://todo:password@localhost:5432/todo"
|
||||
db, err := sql.Open("pgx", postgresUrl)
|
||||
// db, err := sql.Open("pgx", postgresUrl)
|
||||
db, err := pgxpool.New(context.Background(), postgresUrl)
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
os.Exit(1);
|
||||
|
||||
Reference in New Issue
Block a user