This commit is contained in:
huangsimin 2018-12-10 14:10:24 +08:00
parent 1685ff59ff
commit 5f27051688
2 changed files with 8 additions and 1 deletions

View File

@ -40,6 +40,11 @@ func NewLogDB(filename string) *LogDB {
return &logdb
}
// Ping 是否Ping通数据库
func (logdb *LogDB) Ping() error {
return logdb.driver.Ping()
}
// Connect 重连
func (logdb *LogDB) Connect() {
defer func() {
@ -67,5 +72,6 @@ func (logdb *LogDB) Connect() {
if err != nil {
panic(err)
}
db.Ping()
logdb.driver = db
}

View File

@ -14,7 +14,8 @@ import (
// user: spider
func TestSelect(t *testing.T) {
logdb := NewLogDB("logdb.yaml")
t.Error(logdb)
logdb.Connect()
t.Error(logdb)
}