2018-06-19 15:20:02 +02:00
|
|
|
package data
|
2018-05-07 14:07:37 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
|
|
|
|
"git.fuyu.moe/5GPowerQuality/parser/internal/migrations"
|
|
|
|
"git.ultraware.nl/NiseVoid/qb/driver/autoqb"
|
2018-06-19 15:20:02 +02:00
|
|
|
"git.ultraware.nl/NiseVoid/qb/qbdb"
|
2018-05-07 14:07:37 +02:00
|
|
|
|
|
|
|
_ "github.com/lib/pq" // PostgreSQL driver
|
|
|
|
)
|
|
|
|
|
2018-06-19 15:20:02 +02:00
|
|
|
var db *qbdb.DB
|
|
|
|
|
|
|
|
func InitDB() {
|
2018-05-07 14:07:37 +02:00
|
|
|
d, err := sql.Open(`postgres`, `host=/tmp dbname=power_quality`)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = migrations.RunMigrations(d)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
db = autoqb.New(d)
|
|
|
|
|
|
|
|
}
|