Enha: sqlx instead of pgx

This commit is contained in:
Grail Finder
2025-07-01 16:00:17 +03:00
parent 70f83f1002
commit e989590e74
18 changed files with 631 additions and 72 deletions

View File

@ -1,11 +1,11 @@
package repos
import (
"context"
"log/slog"
"os"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
)
type AllRepos interface {
@ -15,17 +15,17 @@ type AllRepos interface {
}
type RepoProvider struct {
DB *pgxpool.Pool
DB *sqlx.DB
}
func NewRepoProvider(pathToDB string) *RepoProvider {
dbpool, err := pgxpool.New(context.Background(), pathToDB)
db, err := sqlx.Connect("sqlite3", pathToDB)
if err != nil {
slog.Error("Unable to connect to database", "error", err)
os.Exit(1)
}
slog.Info("Successfully connected to database")
return &RepoProvider{
DB: dbpool,
DB: db,
}
}