package dbm

import (
	"github.com/tangs-drm/go-tool/dbm"
	"github.com/tangs-drm/go-tool/log"
	"io/ioutil"
)

var Db = func() *dbm.DB {
	return dbm.DefaultDBManger.D()
}

func Init(path string) error {
	bys, err := ioutil.ReadFile(path)
	if err != nil {
		return err
	}

	err = Db().ExecScripts(string(bys), true)
	if err != nil {
		return err
	}

	log.Debug("[Init] dbm init db with path(%v) success", path)
	return nil
}
