goipam/db/sqlite.go

19 lines
355 B
Go
Raw Permalink Normal View History

2024-02-22 10:18:59 +01:00
package db
import (
"log"
"github.com/spf13/viper"
"gorm.io/driver/sqlite" // Sqlite driver based on CGO
"gorm.io/gorm"
)
func connectSQLite() *gorm.DB {
sqlDB := sqlite.Open(viper.GetString("db.path"))
connection, err := gorm.Open(sqlDB, &gorm.Config{})
if err != nil {
log.Fatal("Could not connect to Database", err)
}
return connection
}