Documentation ¶
Index ¶
- func BeginTx() (*yeeTx, error)
- func ClearRegisterTable()
- func Debug(b bool)
- func DeleteByID(tableName, fieldName, value string) error
- func Exec(query string, args ...interface{}) (sql.Result, error)
- func GetAllInTable(tableName string) ([]map[string]string, error)
- func GetDb() *sqlx.DB
- func GetDbWithoutDbName() *sqlx.DB
- func GetOneWhere(tableName, fieldName, value string) (map[string]string, error)
- func InitDb()
- func InitDbWithoutDbName()
- func Insert(tableName string, row map[string]string) (lastInsertID int, err error)
- func IsExist(tableName string, row map[string]string) bool
- func MustAddField(table Table, filedName string)
- func MustCreateDb()
- func MustCreateTable(table Table)
- func MustDeleteByID(tableName, fieldName, value string)
- func MustDropDb()
- func MustDropTable(tableName string)
- func MustExec(query string, args ...interface{})
- func MustForceModifyTable(table Table)
- func MustForceSyncRegisterTable()
- func MustForceSyncTable(table Table)
- func MustGetAllInTable(tableName string) []map[string]string
- func MustGetOneWhere(tableName, fieldName, value string) map[string]string
- func MustInsert(tableName string, row map[string]string) (lastInsertID int)
- func MustIsTableExist(tableName string) bool
- func MustModifyTable(table Table)
- func MustQuery(query string, args ...interface{}) (output []map[string]string)
- func MustQueryOne(query string, args ...interface{}) map[string]string
- func MustRegisterTable(table Table)
- func MustRunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string)
- func MustSetDbConfig(conf *DbConfig)
- func MustSetTableDataToml(data string)
- func MustSyncRegisterTable()
- func MustSyncTable(table Table)
- func MustUpdateByID(tableName string, primaryKeyName string, row map[string]string)
- func MustVerifyDbConfig()
- func MustVerifyTableConfig(table Table)
- func Query(query string, args ...interface{}) (output []map[string]string, err error)
- func QueryOne(query string, args ...interface{}) (output map[string]string, err error)
- func RowsToMapSlice(rows *sql.Rows) (output []map[string]string)
- func RowsToMapSliceFirst(rows *sql.Rows) (map[string]string, error)
- func RunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string, err error)
- func UpdateByID(tableName string, primaryKeyName string, row map[string]string) error
- type DbConfig
- type DbType
- type MysqlDataType
- type MysqlField
- type MysqlFieldType
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllInTable ¶
GetAllInTable 获取表中全部数据
func GetDbWithoutDbName ¶
func GetOneWhere ¶
GetOneWhere 通过某个字段的值查找一条数据
func InitDbWithoutDbName ¶
func InitDbWithoutDbName()
func MustCreateTable ¶
func MustCreateTable(table Table)
MustCreateTable 根据table建表
CREATE TABLE IF NOT EXISTS `test` ( ID int(11) unsigned AUTO_INCREMENT, Name varchar(255) COLLATE utf8_bin DEFAULT "" NOT NULL, Account varchar(255) COLLATE utf8_bin DEFAULT "" NOT NULL, PRIMARY KEY (`ID`), UNIQUE INDEX (`Account`,`Name`) ) engine=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
func MustDeleteByID ¶
func MustDeleteByID(tableName, fieldName, value string)
func MustDropDb ¶
func MustDropDb()
func MustForceSyncRegisterTable ¶
func MustForceSyncRegisterTable()
MustForceSyncRegisterTable 强制同步注册进去的表(可能会缺失字段,保证字段达到配置的样子) 不能并发调用
func MustForceSyncTable ¶
func MustForceSyncTable(table Table)
MustForceSyncTable 强制更新表 可能会缺失字段,保证字段达到配置的样子
func MustGetAllInTable ¶
func MustGetOneWhere ¶
func MustQueryOne ¶
func MustRegisterTable ¶
func MustRegisterTable(table Table)
MustRegisterTable 向系统中注册表 不能重复注册 不能并发调用
func MustRunSelectCommand ¶
func MustRunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string)
func MustSetDbConfig ¶
func MustSetDbConfig(conf *DbConfig)
func MustSetTableDataToml ¶
func MustSetTableDataToml(data string)
MustSetTableDataToml 为数据库table设置数据 toml格式 需要注意: 1.会清除表的数据 2.需要设置好自增字段的值(比数据库最大的+1)
func MustSyncRegisterTable ¶
func MustSyncRegisterTable()
MustSyncRegisterTable 同步注册进去的表(只会增加字段,保证不掉数据,会使用fmt显示有哪些字段存在问题.) 不能并发调用
func MustSyncTable ¶
func MustSyncTable(table Table)
MustSyncTable 同步更新表数据 只会增加字段,保证不掉数据,会使用fmt显示有哪些字段存在问题
func MustUpdateByID ¶
func MustVerifyTableConfig ¶
func MustVerifyTableConfig(table Table)
MustVerifyTableConfig 检测table的字段正确性,不能有重复字段(忽略大小写)
func RowsToMapSlice ¶
RowsToMapSlice 将*sql.Row读取到[]map[string]string
func RunSelectCommand ¶
func RunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string, err error)
RunSelectCommand 执行一条selectCommand
Types ¶
type DbConfig ¶
type DbConfig struct { UserName string // 用户名 example: root Password string // 密码 example: password Host string // 数据库主机地址 example: 127.0.0.1 Port string // 数据库端口 example: 3306 DbName string // 数据库名称 example: yee_test }
DbConfig 数据库配置
func GetDbConfig ¶
func GetDbConfig() DbConfig
func (*DbConfig) GetDsnWithoutDbName ¶
GetDsnWithoutDbName
type DbType ¶
type DbType string
const ( DbTypeInt DbType = `int(11) DEFAULT 0` DbTypeIntAutoIncrement DbType = `int(11) unsigned AUTO_INCREMENT` DbTypeString DbType = `varchar(255) COLLATE utf8mb4_bin DEFAULT ""` DbTypeLongString DbType = `longtext COLLATE utf8mb4_bin DEFAULT ""` DbTypeFloat DbType = `float default 0` DbTypeDatetime DbType = `datetime DEFAULT "1970-01-01 00:08:00"` DbTypeBool DbType = `tinyint(4) DEFAULT 0` DbTypeLongBlob DbType = `LONGBLOB` )
func (DbType) GetMysqlFieldType ¶
func (t DbType) GetMysqlFieldType() MysqlFieldType
type MysqlDataType ¶
type MysqlDataType string
const ( MysqlDataTypeVarchar MysqlDataType = `varchar` MysqlDataTypeInt32 MysqlDataType = `int` MysqlDataTypeLongText MysqlDataType = `longtext` MysqlDataTypeFloat MysqlDataType = `float` MysqlDataTypeDateTime MysqlDataType = `datetime` MysqlDataTypeInt8 MysqlDataType = `tinyint` MysqlDataTypeLongBlob MysqlDataType = `longblob` )
type MysqlField ¶
type MysqlField struct { Name string Type MysqlFieldType }
type MysqlFieldType ¶
type MysqlFieldType struct { DataType MysqlDataType IsUnsigned bool IsAutoIncrement bool CharacterSetName string //utf8 CollationName string //utf8_bin Default string StringLength int }
func (MysqlFieldType) Equal ¶
func (t1 MysqlFieldType) Equal(t2 MysqlFieldType) bool
func (MysqlFieldType) String ¶
func (t1 MysqlFieldType) String() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.