Documentation ¶
Index ¶
- func ClearReisterTable()
- func DeleteById(tableName string, fieldName string, value string) error
- func Exec(query string, args ...string) (sql.Result, error)
- func GetAllInTable(tableName string) (output []map[string]string, err error)
- func GetFirstIntFromRowList(rowList []map[string]string) int
- func GetOneWhere(tableName string, fieldName string, value string) (output map[string]string, err error)
- func HasProdConfig() bool
- func HasTestConfig() bool
- func Insert(tableName string, row map[string]string) (lastInsertId int, err error)
- func LoadConfigWithDbName(dbname string)
- func MustAddNewField(tableConf Table, newFieldName string)
- func MustCreateDb()
- func MustCreateTable(tableConf Table)
- func MustDeleteById(tableName string, fieldName string, value string)
- func MustExec(query string, args ...string)
- func MustForceModifyTable(tableConf Table)
- func MustForceSyncDefaultDbConfig()
- func MustForceSyncRegisterTable()
- func MustForceSyncTable(tableConf Table)
- func MustGetAllInTable(tableName string) (output []map[string]string)
- func MustGetOneWhere(tableName string, fieldName string, value string) (output map[string]string)
- func MustInsert(tableName string, row map[string]string) (lastInsertId int)
- func MustIsTableExist(tableName string) bool
- func MustLoadProdConfig()
- func MustLoadTestConfig()
- func MustModifyTable(tableConf Table)
- func MustOrmFromId(obj OrmObject, id string)
- func MustOrmFromRow(obj OrmObject, row map[string]string)
- func MustOrmInsert(obj OrmObject)
- func MustOrmPersist(obj OrmObject)
- func MustOrmToRow(obj OrmObject) (row map[string]string)
- func MustOrmUpdate(obj OrmObject)
- func MustPing()
- func MustQuery(query string, args ...string) []map[string]string
- func MustQueryOne(query string, args ...string) map[string]string
- func MustRegisterTable(table Table)
- func MustReplaceById(tableName string, primaryKeyName string, row map[string]string) (lastInsertId int)
- func MustRunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string)
- func MustSetTableDataYaml(yaml string)
- func MustSyncDefaultDbConfig()
- func MustSyncRegisterTable()
- func MustSyncTable(tableConf Table)
- func MustTransactionCallback(f func(tx Tx))
- func MustUpdateById(tableName string, primaryKeyName string, row map[string]string)
- func MustVerifyTableConfig(tableConf Table)
- func OrmPersist(obj OrmObject) (lastInsertId int, err error)
- func OrmToRow(obj OrmObject) (row map[string]string, err error)
- func Ping() (err error)
- func Query(query string, args ...string) (output []map[string]string, err error)
- func QueryOne(query string, args ...string) (output map[string]string, err error)
- func ReplaceById(tableName string, primaryKeyName string, row map[string]string) (lastInsertId int, err error)
- func SetDefaultDbConfig(conf *DbConfig)
- func SyncDbCommand()
- func TransactionCallback(db TransactionableDb, f func() error) (err error)
- func UpdateById(tableName string, primaryKeyName string, row map[string]string) error
- type DB
- func (q DB) Exec(query string, args ...string) (sql.Result, error)
- func (db *DB) GetTableData(tableName string) (output []map[string]string, err error)
- func (db *DB) GetTableDataMap(tableName string, pkName string) (output map[string]map[string]string, err error)
- func (db *DB) MustGetTableData(tableName string) (output []map[string]string)
- func (db *DB) MustGetTableDataMap(tableName string, pkName string) (output map[string]map[string]string)
- func (db DB) MustSetTablesDataYaml(yaml string)
- func (q DB) Query(query string, args ...string) (output []map[string]string, err error)
- func (db DB) SetTablesData(data map[string][]map[string]string) (err error)
- func (db DB) SetTablesDataYaml(yaml string) (err error)
- type DbConfig
- type DbQueryer
- func (q DbQueryer) DeleteById(tableName string, fieldName string, value string) error
- func (q DbQueryer) Exec(query string, args ...string) (sql.Result, error)
- func (q DbQueryer) GetAllInTable(tableName string) (output []map[string]string, err error)
- func (q DbQueryer) GetOneWhere(tableName string, fieldName string, value string) (output map[string]string, err error)
- func (q DbQueryer) Insert(tableName string, row map[string]string) (lastInsertId int, err error)
- func (q DbQueryer) MustRunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string)
- func (q DbQueryer) Query(query string, args ...string) (output []map[string]string, err error)
- func (q DbQueryer) QueryOne(query string, args ...string) (output map[string]string, err error)
- func (q DbQueryer) ReplaceById(tableName string, primaryKeyName string, row map[string]string) (lastInsertId int, err error)
- func (q DbQueryer) UpdateById(tableName string, primaryKeyName string, row map[string]string) error
- type DbType
- type MysqlDataType
- type MysqlField
- type MysqlFieldType
- type OrmObject
- type SqlQueryer
- type SqlTxer
- type Table
- type TestDbConf
- type TransactionableDb
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFirstIntFromRowList ¶
func GetOneWhere ¶
func GetOneWhere(tableName string, fieldName string, value string) (output map[string]string, err error)
如果没有数据不会报错,output和err都会返回nil
func HasProdConfig ¶
func HasProdConfig() bool
func HasTestConfig ¶
func HasTestConfig() bool
func LoadConfigWithDbName ¶
func LoadConfigWithDbName(dbname string)
func MustAddNewField ¶
func MustCreateTable ¶
func MustCreateTable(tableConf Table)
func MustDeleteById ¶
func MustForceModifyTable ¶
func MustForceModifyTable(tableConf Table)
func MustForceSyncDefaultDbConfig ¶
func MustForceSyncDefaultDbConfig()
func MustForceSyncRegisterTable ¶
func MustForceSyncRegisterTable()
强制同步注册进去的表,可能会掉数据,保证字段达到配置的样子 不支持并发调用
func MustForceSyncTable ¶
func MustForceSyncTable(tableConf Table)
func MustGetAllInTable ¶
func MustGetOneWhere ¶
func MustIsTableExist ¶
func MustLoadProdConfig ¶
func MustLoadProdConfig()
func MustLoadTestConfig ¶
func MustLoadTestConfig()
func MustModifyTable ¶
func MustModifyTable(tableConf Table)
func MustOrmFromId ¶
func MustOrmFromRow ¶
func MustOrmInsert ¶
func MustOrmInsert(obj OrmObject)
func MustOrmPersist ¶
func MustOrmPersist(obj OrmObject)
func MustOrmToRow ¶
func MustOrmUpdate ¶
func MustOrmUpdate(obj OrmObject)
func MustReplaceById ¶
func MustRunSelectCommand ¶
func MustRunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string)
func MustSyncRegisterTable ¶
func MustSyncRegisterTable()
同步注册进去的表(只会增加字段,保证不掉数据,会使用fmt显示有哪些字段存在问题. 不支持并发调用
func MustSyncTable ¶
func MustSyncTable(tableConf Table)
func MustUpdateById ¶
func MustVerifyTableConfig ¶
func MustVerifyTableConfig(tableConf Table)
func OrmPersist ¶
func ReplaceById ¶
func SetDefaultDbConfig ¶
func SetDefaultDbConfig(conf *DbConfig)
func SyncDbCommand ¶
func SyncDbCommand()
func TransactionCallback ¶
func TransactionCallback(db TransactionableDb, f func() error) (err error)
@deprecated transaction callback on beego.orm,but not depend on it 有可能会多次运行
Types ¶
type DB ¶
a wrap of database/sql.Db 表示一个数据库 这个可以建立很多连接
func (*DB) GetTableData ¶
get all data of a table mostly for test
func (*DB) GetTableDataMap ¶
func (*DB) MustGetTableData ¶
func (*DB) MustGetTableDataMap ¶
func (DB) SetTablesData ¶
@deprecated Set some tables data in this database. mostly for test not guarantee next increment id will be!! 设置表数据 注意:
- 会删除数据
- 保证 auto_increase 的值是数据里面的最大值+1
type DbConfig ¶
type DbConfig struct { Username string // example: root Password string // example: password Host string // example: 127.0.0.1 DbName string // example: kmg_test }
func GetDbConfigFromConfig ¶
@deprecated
func GetDefaultDbConfig ¶
func GetDefaultDbConfig() *DbConfig
func (*DbConfig) GetDsnWithoutDbName ¶
type DbQueryer ¶
type DbQueryer struct {
SqlQueryer
}
表示一个数据库Queryer 可以拿去查数据库,
func (DbQueryer) DeleteById ¶
func (DbQueryer) GetAllInTable ¶
func (DbQueryer) GetOneWhere ¶
func (DbQueryer) MustRunSelectCommand ¶
func (q DbQueryer) MustRunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string)
func (DbQueryer) ReplaceById ¶
type DbType ¶
type DbType string
const ( DbTypeInt DbType = `int(11) DEFAULT 0` DbTypeIntAutoIncrement DbType = `int(11) unsigned AUTO_INCREMENT` DbTypeString DbType = `varchar(255) COLLATE utf8_bin DEFAULT ""` DbTypeLongString DbType = `longtext COLLATE utf8_bin DEFAULT ""` DbTypeFloat DbType = `float default 0` DbTypeDatetime DbType = `datetime DEFAULT "0000-00-00 00:00: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
type SqlQueryer ¶
type Table ¶
type Table struct { Name string FieldList map[string]DbType PrimaryKey string UniqueKey [][]string Null []string }
读取数据库的表字段,不区分大小写(某些系统的mysql不区分大小写) 写入数据库的表字段,区分大小写
type TestDbConf ¶
type TestDbConf struct {
Db *DbConfig
}
type TransactionableDb ¶
@deprecated
Source Files ¶
Click to show internal directories.
Click to hide internal directories.