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("test.db"), &gorm.Config{})
15
16 if err != nil {
17 panic("failed to connect to the database.")
18 }
19
20 DB.AutoMigrate(&Entry{})
21}