goProject/trunk/center/dbcenter/internal/db_heandler.go
2025-01-23 16:12:49 +08:00

38 lines
605 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package internal
import (
"common/connection"
"goutil/logUtilPlus"
)
// ExecSql 执行sql
func ExecSql(sql string) error {
defer func() error {
if err := recover(); err != nil {
logUtilPlus.ErrorLog("mq远程执行sql异常对应sql%s", sql)
//写入失败的文件,便于后续排查
AddSqlErr(sql)
}
return nil
}()
//获取数据库连接
db := connection.GetAdminDB()
logUtilPlus.InfoLog("执行sql:%s", sql)
//执行sql
err := db.Exec(sql).Error
//判断错误
if err != nil {
//记录错误
logUtilPlus.ErrorLog("ExecSql error:", err)
}
return nil
}