18 lines
310 B
Go
18 lines
310 B
Go
|
package infrastructure
|
||
|
|
||
|
import (
|
||
|
"gorm.io/driver/sqlite"
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
func ConnectToSqlite() (*gorm.DB, error) {
|
||
|
dsn := "test.db"
|
||
|
//dsn := "file::memory:?cache=shared"
|
||
|
db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{})
|
||
|
if err != nil {
|
||
|
panic("failed to connect database")
|
||
|
}
|
||
|
|
||
|
return db, nil
|
||
|
}
|