Initial commit

This commit is contained in:
Magnus Åhall 2025-08-05 22:58:36 +02:00
commit dc8a638814
4 changed files with 209 additions and 0 deletions

31
db.go Normal file
View file

@ -0,0 +1,31 @@
package main
import (
// External
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
// Standard
"fmt"
)
var (
db *sqlx.DB
)
func initDB(host string, port int, dbName, username, password string) (err error) { // {{{
dbConn := fmt.Sprintf(
"host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
host,
port,
username,
password,
dbName,
)
if db, err = sqlx.Connect("postgres", dbConn); err != nil {
return
}
return
} // }}}