main.go 888 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. "git.wecise.com/wecise/cgimport/importer"
  6. "git.wecise.com/wecise/cgimport/odbc"
  7. )
  8. // 获取配置信息
  9. //
  10. // 默认配置:
  11. // 当前工作目录下 与应用同名的 .conf 文件
  12. // 环境变量
  13. // 命令行参数
  14. var mcfg = odbc.Config
  15. var logger = odbc.Logger
  16. func main() {
  17. // 开始计时
  18. st := time.Now()
  19. // 配置参数
  20. // 文件目录
  21. datapath := mcfg.GetString("datapath", "data")
  22. // 并发数
  23. parallel := mcfg.GetInt("parallel", 10)
  24. // 导入
  25. filescount, recordscount, e := importer.ImportDir(datapath, parallel)
  26. if e != nil {
  27. panic(e)
  28. }
  29. if filescount == 0 {
  30. fmt.Println(`not found data files in "` + datapath + `"`)
  31. return
  32. }
  33. // 输出统计信息
  34. fmt.Println("total import", filescount, "files", recordscount, "records", "in", time.Since(st))
  35. fmt.Println("access", odbc.LogFile, "for detail information")
  36. }