From 6b8f2fcab8b2db599481fe2aa13ee97b63811d37 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 2 Aug 2015 07:37:33 +0800 Subject: [PATCH] Send a ping to make sure the database connection is alive, thanks @pariz --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index dbac3b33..30802205 100644 --- a/main.go +++ b/main.go @@ -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