package
0.0.0-20240430070110-32c8d490bf49
Repository: https://github.com/eachain/common.git
Documentation: pkg.go.dev

# Functions

AllFields 用于select语句,返回fieldNames和fieldValues。 fieldNames用于生成sql, fieldValues用于row.Scan(values...)。 fieldNames和fieldValues是一一对应的。 用法: var t T names, fields := AllFields(&t) sql := "SELECT " + names + " FROM " + table + " LIMIT 1" err := db.QueryRow(sql).Scan(fields...) */.
CloseAll 应该在主线程中被调用,比如进程退出前。.
No description provided by the author
Init 初始化并注册所有需要的sql.DB。.
InsertRow v只允许map[string]interface{}和struct类型, 类型内部不允许嵌套复杂类型。用法: t := &T{...} result, err := mysql.InsertRow("biz_name", "table_name", t) if err != nil { ..
InsertRows 参数v必须是slice of struct类型。 在a slice of struct中,不要某些用omitempty默认值,有些不用。 否则有可能会因为字段对不上而panic。用法: type T struct { ID int64 `db:"id,omitempty"` // 除了id,其他字段最好不用omitempty ..
IsDup 用于判断mysql insert返回的error是不是duplicate, 即出现primary/unique冲突。 例: _, err := InsertRow(biz, table, &T{...}) if err != nil { if IsDup(err) { ..

# Variables

No description provided by the author

# Structs

ConfigInfo 包含mysql初始化信息。.
No description provided by the author
SelectSQL用于select语句, 函数名和select语法保持一致, 参数和database/sql一样, 用?标记.
No description provided by the author