first commit

This commit is contained in:
2023-04-15 16:23:34 +07:00
commit bbed7f94f4
20 changed files with 533 additions and 0 deletions

13
database/database.go Normal file
View 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
View 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)
}