change db to fixed name and path is definable

This commit is contained in:
Adrian Zürcher
2025-10-24 11:01:52 +02:00
parent d7890f747b
commit a797700685
3 changed files with 8 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ package AccessHandler
import (
"errors"
"fmt"
"path/filepath"
"reflect"
"strings"
@@ -43,8 +44,9 @@ type DBHandler struct {
// Returns:
// - dH: A pointer to the initialized `DBHandler`.
// - err: Any error encountered during database connection.
func NewDBHandler(dbPath string, logger *logging.Logger) (dH *DBHandler, err error) {
func NewDBHandler(path string, logger *logging.Logger) (dH *DBHandler, err error) {
dH = &DBHandler{logger: logger}
dbPath := filepath.Join(path, "user.db")
logger.Debug("NewDBHandler", "open database "+dbPath)
dH.db, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
return