aboutsummaryrefslogtreecommitdiffstats
path: root/models/db.go
blob: 31d8bdd7f03ad661e604d8a995be945c8e92fdd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
Package neko/models implements behavior for the entities necessary for the subscription services and handles persistence via a mysql/maridb database
*/
package models

import (
	"adammathes.com/neko/config"
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
	_ "github.com/mattn/go-sqlite3"
	"log"
)

var DB *sql.DB

func InitDB() {
	var err error
	//    DB, err = sql.Open("mysql", dataSourceName)
	DB, err = sql.Open(config.Config.DBDriver, config.Config.DBServer)
	if err != nil {
		log.Panic(err)
	}

	if err = DB.Ping(); err != nil {
		log.Panic(err)
	}
}