mirror of
https://github.com/dancojocaru2000/CfrTrainInfoTelegramBot.git
synced 2025-02-22 09:09:38 +02:00
Make DB path configurable
This commit is contained in:
parent
97e6d78ce6
commit
69a0cf3a01
1 changed files with 7 additions and 1 deletions
8
main.go
8
main.go
|
@ -59,7 +59,13 @@ func main() {
|
|||
log.Fatal("ERROR: No bot token supplied; supply with CFR_BOT.TOKEN")
|
||||
}
|
||||
|
||||
db, err := gorm.Open(sqlite.Open("bot_db.sqlite"), &gorm.Config{})
|
||||
dbPath := os.Getenv("CFR_BOT.DB_PATH")
|
||||
dbPath = strings.TrimSpace(dbPath)
|
||||
if len(dbPath) == 0 {
|
||||
dbPath = "bot_db.sqlite"
|
||||
}
|
||||
log.Printf("INFO : DB Path: %s\n", dbPath)
|
||||
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue