Send a ping to make sure the database connection is alive, thanks @pariz

This commit is contained in:
Jinzhu 2015-08-02 07:37:33 +08:00
parent 0def184b0c
commit 6b8f2fcab8
1 changed files with 4 additions and 0 deletions

View File

@ -73,6 +73,10 @@ func Open(dialect string, args ...interface{}) (DB, error) {
db: dbSql,
}
db.parent = &db
if err == nil {
err = db.DB().Ping() // Send a ping to make sure the database connection is alive.
}
}
return db, err