server: use postgres instead of scylla, easier to host

This commit is contained in:
2026-05-15 02:20:53 +00:00
parent c1c8a3d6aa
commit 26b00f8566
7 changed files with 106 additions and 66 deletions
+27
View File
@@ -0,0 +1,27 @@
package db
import (
"context"
"log/slog"
"os"
"github.com/jackc/pgx/v5/pgxpool"
)
var Pool *pgxpool.Pool
func InitPostgres(ctx context.Context) {
pool, err := pgxpool.New(ctx, os.Getenv("DATABASE_URL"))
if err != nil {
slog.Error("Failed to connect to Postgres", "error", err)
os.Exit(1)
}
Pool = pool
slog.Info("Connected to Postgres")
}
func ClosePostgres() {
if Pool != nil {
Pool.Close()
}
}