midr @ a4cd5de795926537318f94aa34c9f2579c29fc11

 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}