Documentation
¶
Index ¶
- Constants
- Variables
- func BuiltinEnvs(envs map[string]string)
- func Diff(pref *Preference, srce *DataSource, dest []*DataSource, kind string, ...) error
- func Exec(pref *Preference, dest []*DataSource, file []FileEntity, risk bool) error
- func ExitIfError(err error, code int, format string, args ...interface{})
- func ExitIfTrue(tru bool, code int, format string, args ...interface{})
- func LogError(m string, a ...interface{})
- func LogTrace(m string, a ...interface{})
- func OutDebug(m string, a ...interface{})
- func OutTrace(m string, a ...interface{})
- func Revi(pref *Preference, dest []*DataSource, file []FileEntity, ...) error
- func ReviEach(pref *Preference, revs []ReviSeg, conn Conn, slt string, mask *regexp.Regexp, ...)
- func RunSqlx(pref *Preference, sqlx *SqlExe, src *MyConn, dst []*MyConn, risk bool) error
- func Sync(srce *DataSource, dest []*DataSource, kind string, rgx []*regexp.Regexp) error
- func Tree(pref *Preference, envs map[string]string, srce *DataSource, dest []*DataSource, ...) error
- type Arg
- type Col
- type Config
- type Conn
- type CtrlJob
- type DataSource
- type DiffItem
- type Exe
- type FileEntity
- type Hld
- type Idx
- type MyConn
- func (m *MyConn) Columns(table string) (map[string]Col, error)
- func (m *MyConn) DbConn() (db *sql.DB)
- func (m *MyConn) DbName() string
- func (m *MyConn) DdlTable(table string) (string, error)
- func (m *MyConn) DdlTrigger(trigger string) (string, error)
- func (m *MyConn) Exec(qr string, args ...interface{}) (int64, error)
- func (m *MyConn) Indexes(table string) (map[string]Idx, error)
- func (m *MyConn) Literal(val interface{}, col string) (string, bool)
- func (m *MyConn) Nothing(val interface{}) bool
- func (m *MyConn) Open(p *Preference, d *DataSource) (err error)
- func (m *MyConn) Query(fn func(*sql.Rows) error, qr string, args ...interface{}) error
- func (m *MyConn) Quotesc(str, qto string) string
- func (m *MyConn) Tables() ([]string, error)
- func (m *MyConn) Triggers(table string) (map[string]Trg, error)
- type Preference
- type ReviSeg
- type Room
- type Sql
- type SqlExe
- type Sqls
- type Trg
Constants ¶
View Source
const ( CtrlExitcd = 99 CtrlRoomTree = "tree" )
View Source
const ( LvlDebug = 300 LvlTrace = 200 LvlError = 100 // EnvSrcDb = "SRC-DB" EnvOutDb = "OUT-DB" EnvUser = "USER" EnvHost = "HOST" EnvDate = "DATE" EnvRule = "ENV-CHECK-RULE" EnvRuleError = "ERROR" EnvRuleEmpty = "EMPTY" // SqlNull = "NULL" SqlTrue = "TRUE" SqlFalse = "FALSE" // DiffTbl = "tbl" // 分别对比`-s`和多个`-d` 间的表名差异 DiffAll = "all" // 分别对比`-s`和多个`-d` 间的表明细(column, index,trigger) DiffDdl = "ddl" // 生成多库的创建DDL(table&index,trigger) // Joiner = "\n" // SyncTbl = "tbl" // 同步表和索引 SyncAll = "all" // 同步说有 SyncTrg = "trg" // 同步trigger )
View Source
const ( HoldTop = "ITSELF" // CmndEnv = "ENV" CmndRef = "REF" CmndStr = "STR" CmndRun = "RUN" CmndOut = "OUT" // ParaFor = "FOR" ParaOne = "ONE" ParaEnd = "END" ParaHas = "HAS" ParaNot = "NOT" )
Variables ¶
Functions ¶
func BuiltinEnvs ¶
func Diff ¶
func Diff(pref *Preference, srce *DataSource, dest []*DataSource, kind string, rgx []*regexp.Regexp) error
func Exec ¶
func Exec(pref *Preference, dest []*DataSource, file []FileEntity, risk bool) error
func ExitIfTrue ¶
func Revi ¶
func Revi(pref *Preference, dest []*DataSource, file []FileEntity, revi, mask, rqry string, risk bool) error
func Sync ¶ added in v0.9.4
func Sync(srce *DataSource, dest []*DataSource, kind string, rgx []*regexp.Regexp) error
func Tree ¶
func Tree(pref *Preference, envs map[string]string, srce *DataSource, dest []*DataSource, file []FileEntity, risk bool) error
Types ¶
type Config ¶
type Config struct {
Preference Preference
DataSource map[string]DataSource
StartupEnv map[string]string
}
type Conn ¶
type Conn interface {
// 打开链接
Open(p *Preference, d *DataSource) (err error)
// 获得链接
DbConn() (db *sql.DB)
// 数据库名
DbName() string
// 执行脚本
Exec(qr string, args ...interface{}) (cnt int64, err error)
// 执行查询
Query(fn func(*sql.Rows) error, qr string, args ...interface{}) (err error)
// 获得所有表名
Tables() (tbls []string, err error)
// 获得表的所有字段
Columns(table string) (cls map[string]Col, err error)
// 获得表的所有索引
Indexes(table string) (ixs map[string]Idx, err error)
// 获得表的所有触发器
Triggers(table string) (tgs map[string]Trg, err error)
// 生产建表SQL(含索引),包含结束符
DdlTable(table string) (ddl string, err error)
// 生产建触发器SQL,包含结束符
DdlTrigger(trigger string) (ddl string, err error)
// 转成SQL字面量,set x=val的 val部分字面量,是否需要引号扩上
// databaseTypeName sql.ColumnType.DatabaseTypeName
Literal(val interface{}, databaseTypeName string) (string, bool)
// 数值<=0|布尔false|NULL|字符串""|其他字面量为""
Nothing(val interface{}) bool
// 转义的字符串
Quotesc(str, qto string) string
}
type DataSource ¶
type Exe ¶
type FileEntity ¶
func FileWalker ¶
func FileWalker(path []string, flag []string) ([]FileEntity, error)
type MyConn ¶
type MyConn struct {
Pref *Preference
Conn *sql.DB
Name string
}
func (*MyConn) Open ¶
func (m *MyConn) Open(p *Preference, d *DataSource) (err error)
type Preference ¶
type SqlExe ¶
func ParseTree ¶
func ParseTree(pref *Preference, envs map[string]string, file []FileEntity) ([]*SqlExe, error)
type Sqls ¶
type Sqls []Sql
func ParseSqls ¶
func ParseSqls(pref *Preference, file *FileEntity) Sqls
Click to show internal directories.
Click to hide internal directories.