main.go 1.0 KB

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