fix database error

master
兔子 6 years ago
parent 941d54b886
commit dbdb0de0f3

@ -780,6 +780,8 @@ func FetchAll(rows *sql.Rows) (error, map[int]map[string]string) {
switch vtype := col.(type) { switch vtype := col.(type) {
case int64: case int64:
record[columns[i]] = strconv.FormatInt(vtype, 10) record[columns[i]] = strconv.FormatInt(vtype, 10)
case string:
record[columns[i]] = vtype
default: default:
record[columns[i]] = string(vtype.([]byte)) record[columns[i]] = string(vtype.([]byte))
} }
@ -793,6 +795,10 @@ func FetchAll(rows *sql.Rows) (error, map[int]map[string]string) {
func OpenDB(Method, ConnStr string) error { func OpenDB(Method, ConnStr string) error {
var err error var err error
DBRes, err = sql.Open(Method, ConnStr) DBRes, err = sql.Open(Method, ConnStr)
if err != nil {
return err
}
err = DBRes.Ping()
return err return err
} }
func CloseDB() { func CloseDB() {

Loading…
Cancel
Save