first commit
This commit is contained in:
13
database/database.go
Normal file
13
database/database.go
Normal file
@ -0,0 +1,13 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
var db *gorm.DB
|
||||
var err error
|
||||
|
||||
// GetDB : get current connection
|
||||
func GetDB() *gorm.DB {
|
||||
return db
|
||||
}
|
20
database/sqlite.go
Normal file
20
database/sqlite.go
Normal file
@ -0,0 +1,20 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rouggy.com/rouggy/RaceBot/config"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
// SQLiteDBConnect : Create Connection to database
|
||||
func SQLiteDBConnect() {
|
||||
//Connect to database, exit when errored
|
||||
db, err = gorm.Open("sqlite3", "./"+config.DBName+".db")
|
||||
if err != nil {
|
||||
panic("[Database] Failed to connect to database")
|
||||
}
|
||||
fmt.Println("[Database] Database successfully connected")
|
||||
//If set true then print all executed queries to the console
|
||||
db.LogMode(true)
|
||||
}
|
Reference in New Issue
Block a user