CheckDBConnection check database whether the connection is normal
(dataConf *data.Database)
| 38 | |
| 39 | // CheckDBConnection check database whether the connection is normal |
| 40 | func CheckDBConnection(dataConf *data.Database) bool { |
| 41 | db, err := data.NewDB(false, dataConf) |
| 42 | if err != nil { |
| 43 | fmt.Printf("connection database failed: %s\n", err) |
| 44 | return false |
| 45 | } |
| 46 | defer func() { |
| 47 | _ = db.Close() |
| 48 | }() |
| 49 | if err = db.Ping(); err != nil { |
| 50 | fmt.Printf("connection ping database failed: %s\n", err) |
| 51 | return false |
| 52 | } |
| 53 | |
| 54 | return true |
| 55 | } |
| 56 | |
| 57 | // CheckDBTableExist check database whether the table is already exists |
| 58 | func CheckDBTableExist(dataConf *data.Database) bool { |
no test coverage detected