mysql

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIniConfig added in v0.0.9

func FormatIniConfig(section *ini.Section) (map[string]any, error)

FormatIniConfig 格式化 ini 配置

func GetConfig added in v0.0.9

func GetConfig(name string) (map[string]any, error)

GetConfig 获取配置项

func GetConfigs added in v0.0.9

func GetConfigs(name string) map[string]map[string]any

GetConfigs 获取配置项

func SetConfig added in v0.0.9

func SetConfig(name string, config map[string]any)

Types

type Db

type Db struct {
	// contains filtered or unexported fields
}

func GetDb added in v0.0.9

func GetDb(name string) (*Db, error)

GetDb 获取数据库实例

func GetDbByConfig added in v0.0.9

func GetDbByConfig(config map[string]any) (*Db, error)

GetDbByConfig 按配置文件创建数据库实例

func (*Db) Delete

func (db *Db) Delete(table string, where map[string]any) (sql.Result, error)

Delete 删除

func (*Db) Exec

func (db *Db) Exec(sql string, args ...any) (sql.Result, error)

Exec 执行,用于 insert / update / delete

func (*Db) GetConfig added in v0.0.9

func (db *Db) GetConfig() *DbConfig

GetConfig 参数配置

func (*Db) GetMap

func (db *Db) GetMap(sql string, args ...any) (map[string]string, error)

GetMap 查询一行记录

func (*Db) GetMaps

func (db *Db) GetMaps(sql string, args ...any) ([]map[string]string, error)

GetMaps 查询多行记录

func (*Db) GetValue

func (db *Db) GetValue(sql string, args ...any) (string, error)

GetValue 查询一个字段的值

func (*Db) GetValues

func (db *Db) GetValues(sql string, args ...any) ([]string, error)

GetValues 查询一个字段的值

func (*Db) Init

func (db *Db) Init() error

Init 初始化

func (*Db) Insert

func (db *Db) Insert(table string, data map[string]any) (sql.Result, error)

Insert 插入数据

func (*Db) Query

func (db *Db) Query(sql string, args ...any) (*sql.Rows, error)

Query 查询,返回查询结果集,用于 select

func (*Db) SetConfig added in v0.0.9

func (db *Db) SetConfig(config map[string]any)

SetConfig 参数配置

func (*Db) Truncate

func (db *Db) Truncate(table string) (sql.Result, error)

Truncate 清空表

func (*Db) Update

func (db *Db) Update(table string, data map[string]any, primaryKeys ...string) (sql.Result, error)

Update 更新数据

type DbConfig added in v0.0.9

type DbConfig struct {
	// contains filtered or unexported fields
}

type Table added in v0.0.9

type Table struct {
	// contains filtered or unexported fields
}

func (*Table) SetDb added in v0.0.9

func (table *Table) SetDb(db *Db)

SetDb 设置数据库

func (*Table) SetName added in v0.0.9

func (table *Table) SetName(name string)

SetName 设置名称

type Tuple added in v0.0.9

type Tuple struct {
	// contains filtered or unexported fields
}

func (*Tuple) SetDb added in v0.0.9

func (tuple *Tuple) SetDb(db *Db)

SetDb 设置数据库

func (*Tuple) SetName added in v0.0.9

func (tuple *Tuple) SetName(name string)

SetName 设置名称

func (*Tuple) SetStruct added in v0.0.9

func (tuple *Tuple) SetStruct(s any)

SetStruct 设置结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL