Documentation
¶
Index ¶
- Constants
- Variables
- func Close()
- func Execute(sqlStr string, args ...interface{}) (int64, error)
- func Initialize(filename string) error
- func InitializeDatabase(dbType, host string, port int, user, pwd, dbName string) error
- func InitializeFromSettings(cm map[string]string) error
- func LoadProperties(filename string) map[string]string
- func LoadSettings(filename string) map[string]string
- func NewMapper(name string) interface{}
- func NewMapperPtr(name string) interface{}
- func Query(sqlStr string, args ...interface{}) ([]map[string]interface{}, error)
- func ReConnect() error
- func RegisterMapper(inPtr interface{}) error
- func RegisterModel(inPtr interface{})
- func SchemaToCode(dir, prefix, tables string)
- func SetLogger(logger log.Logger)
- type BaseMapper
- type Config
- type ConnPool
- type DB
- func (db *DB) DB() (*sql.DB, error)
- func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (db *DB) Stats() sql.DBStats
- type DatabaseSetting
- type DatabaseType
- type Dialector
- type GetDBConnector
- type MyBatisSetting
- type MySqlConfig
- type MySqlDialector
- type ParamType
- type PostgresConfig
- type PostgresDialector
- type PreparedStmtDB
- func (db *PreparedStmtDB) Close()
- func (db *PreparedStmtDB) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error)
- func (db *PreparedStmtDB) GetDBConn() (*sql.DB, error)
- func (db *PreparedStmtDB) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error)
- func (db *PreparedStmtDB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (db *PreparedStmtDB) Reset()
- func (db *PreparedStmtDB) Stats() sql.DBStats
- type ProxyArg
- type ReturnType
- type Rows
- type Statement
- type Stmt
- type TagArg
Constants ¶
View Source
const ( MySqlDb DatabaseType = "mysql" PostgresDb DatabaseType = "postgres" DefaultMaxIdle = 100 DefaultMaxOpen = 100 DefaultMaxTimeout = 300 )
Variables ¶
View Source
var (
ErrInvalidDB = errors.New("invalid db")
)
Functions ¶
func Initialize ¶
func InitializeDatabase ¶
func InitializeFromSettings ¶
func LoadProperties ¶
func LoadSettings ¶
func NewMapperPtr ¶
func NewMapperPtr(name string) interface{}
func RegisterMapper ¶
func RegisterMapper(inPtr interface{}) error
func RegisterModel ¶
func RegisterModel(inPtr interface{})
func SchemaToCode ¶
func SchemaToCode(dir, prefix, tables string)
Types ¶
type BaseMapper ¶
type Config ¶
type Config struct { Setting MyBatisSetting MaxIdle int MaxOpen int MaxTimeout int PreparedStmt bool SpringConfig bool Dialector ConnPool ConnPool // contains filtered or unexported fields }
func NewConfigFromSettings ¶
func (*Config) DriverName ¶
func (*Config) GenerateDSN ¶
type ConnPool ¶
type ConnPool interface { PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row Stats() sql.DBStats }
type DatabaseSetting ¶
type DatabaseType ¶
type DatabaseType string
type GetDBConnector ¶
type MyBatisSetting ¶
type MyBatisSetting struct { DatabaseSetting MapperLocations string TypeAliasPackage string MaxRows int64 }
type MySqlDialector ¶
type MySqlDialector struct {
*MySqlConfig
}
func NewMySqlDialector ¶
func NewMySqlDialector(cfg *Config) *MySqlDialector
func (*MySqlDialector) FormatPrepareSQL ¶
func (dialector *MySqlDialector) FormatPrepareSQL(src string) string
func (*MySqlDialector) Initialize ¶
func (dialector *MySqlDialector) Initialize(db *DB) (err error)
func (*MySqlDialector) Name ¶
func (dialector *MySqlDialector) Name() string
type PostgresConfig ¶
type PostgresDialector ¶
type PostgresDialector struct {
*PostgresConfig
}
func NewPostgresDialector ¶
func NewPostgresDialector(cfg *Config) *PostgresDialector
func (*PostgresDialector) FormatPrepareSQL ¶
func (dialector *PostgresDialector) FormatPrepareSQL(src string) string
func (*PostgresDialector) Initialize ¶
func (dialector *PostgresDialector) Initialize(db *DB) (err error)
func (*PostgresDialector) Name ¶
func (dialector *PostgresDialector) Name() string
type PreparedStmtDB ¶
type PreparedStmtDB struct { Stmts map[string]*Stmt PreparedSQL []string Mux *sync.RWMutex ConnPool }
func (*PreparedStmtDB) Close ¶
func (db *PreparedStmtDB) Close()
func (*PreparedStmtDB) ExecContext ¶
func (*PreparedStmtDB) QueryContext ¶
func (*PreparedStmtDB) QueryRowContext ¶
func (*PreparedStmtDB) Reset ¶
func (db *PreparedStmtDB) Reset()
func (*PreparedStmtDB) Stats ¶
func (db *PreparedStmtDB) Stats() sql.DBStats
type ReturnType ¶
type Statement ¶
type Statement struct { QueryCount int64 ExecuteCount int64 ErrorCount int64 DurationTotal int64 QueryDuration int64 ExecuteDuration int64 QueryMaxDuration int64 QueryMinDuration int64 ExecuteMaxDuration int64 ExecuteMinDuration int64 DBExecCount int64 DBExecDuration int64 DBExecMaxDuration int64 DBExecMinDuration int64 DBQueryCount int64 DBQueryDuration int64 DBQueryMaxDuration int64 DBQueryMinDuration int64 }
Source Files
¶
- base_mapper.go
- bean_utils.go
- common.go
- database_config.go
- database_connection.go
- database_structure.go
- errors.go
- interfaces.go
- mapper_cache.go
- model_cache.go
- mysql_dialector.go
- orm_cache.go
- orm_init.go
- param_type.go
- postgres_dialector.go
- prepared_stmt.go
- proxy_arg.go
- proxy_value.go
- result_convert.go
- return_type.go
- return_value.go
- schema_utils.go
- sql_cache.go
- sql_execute.go
- statement.go
- table_structure.go
- tag_arg.go
Click to show internal directories.
Click to hide internal directories.