diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/db.go | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,6 +1,8 @@ package db import ( + "path" + "gorm.io/driver/sqlite" "gorm.io/gorm" ) @@ -10,8 +12,10 @@ var ( err error ) -func ConnectDb() { - DB, err = gorm.Open(sqlite.Open("main.db"), &gorm.Config{}) +func ConnectDb(folder string) { + dbPath := path.Join(folder, "main.db") + + DB, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{}) if err != nil { panic("failed to connect to the database.") |