midr @ dc81e33f760b45778f2646d6f1a7c9e8166b2fe5

 1package db
 2
 3import (
 4	"gorm.io/driver/sqlite"
 5	"gorm.io/gorm"
 6)
 7
 8var (
 9	DB  *gorm.DB
10	err error
11)
12
13func ConnectDb() {
14	DB, err = gorm.Open(sqlite.Open("main.db"), &gorm.Config{})
15
16	if err != nil {
17		panic("failed to connect to the database.")
18	}
19
20	DB.AutoMigrate(&Entry{})
21}