Add support for database path from environment variable
This commit is contained in:
10
main.go
10
main.go
@@ -5,6 +5,7 @@ import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"gitea.seeseepuff.be/seeseemelk/mysqlite"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -18,7 +19,14 @@ var templateFS embed.FS
|
||||
|
||||
func main() {
|
||||
log.Println("Starting...")
|
||||
db, err := mysqlite.OpenDb("pcinv.db3")
|
||||
|
||||
// Get database path from environment variable or use default
|
||||
dbPath := os.Getenv("PCINV_DB")
|
||||
if dbPath == "" {
|
||||
dbPath = "pcinv.db3"
|
||||
}
|
||||
|
||||
db, err := mysqlite.OpenDb(dbPath)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening db: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user