aboutsummaryrefslogtreecommitdiffstats
path: root/models/db.go
blob: b8bc655f9f1318fef6628893cb5bcf795b0e9d8b (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
/*
Package neko/models implements behavior for the entities necessary for the subscription services and handles persistence via a mysql/maridb database
*/
package models

import (
    "database/sql"
	_ "github.com/go-sql-driver/mysql"
    "log"
)

var DB *sql.DB

func InitDB(dataSourceName string) {
    var err error
    DB, err = sql.Open("mysql", dataSourceName)
    if err != nil {
        log.Panic(err)
    }

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