change up database configuration to use discrete values for parameters, rather than the raw DSN (database/base.go computes the DSN)

This commit is contained in:
2026-03-12 16:59:19 -06:00
parent 2cc0d0f94d
commit a91202a57e
6 changed files with 54 additions and 42 deletions
+11 -1
View File
@@ -11,6 +11,7 @@ package database
import (
"context"
"fmt"
"slices"
"git.erbosoft.com/amy/amsterdam/config"
@@ -22,10 +23,19 @@ import (
// amdb is the reference to the Amsterdam database.
var amdb *sqlx.DB
// buildMysqlDSN builds the MySQL DSN for the driver.
func buildMysqlDSN() string {
return fmt.Sprintf("%s:%s@tcp(%s)/%s?parseTime=true&loc=UTC",
config.GlobalComputedConfig.DatabaseUser,
config.GlobalComputedConfig.DatabasePassword,
config.GlobalComputedConfig.DatabaseHost,
config.GlobalComputedConfig.DatabaseName)
}
// SetupDb sets up the database and associated items.
func SetupDb() (func(), error) {
exitfns := make([]func(), 0, 2)
db, err := sqlx.Connect(config.GlobalComputedConfig.DatabaseDriver, config.GlobalComputedConfig.DatabaseDSN)
db, err := sqlx.Connect(config.GlobalComputedConfig.DatabaseDriver, buildMysqlDSN())
if err == nil {
amdb = db
g, err := AmGlobals(context.Background())