|
|
@ -14,6 +14,10 @@ import ( |
|
|
|
|
|
|
|
func init() { |
|
|
|
flag.StringVar(&common.ConfigFile, "cf", "config.yml", "配置文件名") |
|
|
|
flag.StringVar(&common.Command, "cmd", "", "命令") |
|
|
|
flag.StringVar(&common.Table, "table", "", "需要迁移的表") |
|
|
|
flag.StringVar(&common.Dbpath, "sqlite", "", "sqlite文件地址") |
|
|
|
flag.StringVar(&common.XlsxPath, "excel", "", "excel文件地址") |
|
|
|
} |
|
|
|
|
|
|
|
func main() { |
|
|
@ -29,17 +33,32 @@ func main() { |
|
|
|
config.Logger.Info("初始化Logger成功...") |
|
|
|
// 判断command
|
|
|
|
command := common.MyEnv.Command |
|
|
|
config.Logger.Infof("Command:%s", common.MyEnv.Command) |
|
|
|
if common.Command != "" { |
|
|
|
command = common.Command |
|
|
|
} |
|
|
|
config.Logger.Infof("Command:%s", command) |
|
|
|
if command == "move_data" { |
|
|
|
// 判断参数
|
|
|
|
table := common.MyEnv.MoveData.Table |
|
|
|
if common.Table != "" { |
|
|
|
table = common.Table |
|
|
|
} |
|
|
|
dbPath := common.MyEnv.MoveData.DBPath |
|
|
|
if common.Dbpath != "" { |
|
|
|
dbPath = common.Dbpath |
|
|
|
} |
|
|
|
// "D:/Work/Code/youtube_dev/youtube-golang/main_program/moveData/channel_region.xlsx"
|
|
|
|
xlsxPath := common.MyEnv.MoveData.XlsxPath |
|
|
|
if common.XlsxPath != "" { |
|
|
|
xlsxPath = common.XlsxPath |
|
|
|
} |
|
|
|
if table == "" || dbPath == "" { |
|
|
|
config.Logger.Error("move_data配置文件错误...") |
|
|
|
return |
|
|
|
} |
|
|
|
config.Logger.Infof("开始调用move_data方法") |
|
|
|
move_data.MoveDataService.Start(table, dbPath, common.MyEnv.Mysql) |
|
|
|
config.Logger.Infof("table:%s dbPath:%s xlsxPath:%s", table, dbPath, xlsxPath) |
|
|
|
move_data.MoveDataService.Start(table, dbPath, common.MyEnv.Mysql, xlsxPath) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|