main.go 734 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. "log"
  6. "os"
  7. )
  8. // FileToList ...
  9. func FileToList(filename string) []string {
  10. var lines []string
  11. file, err := os.Open(filename)
  12. if err != nil {
  13. log.Panic(err)
  14. }
  15. scanner := bufio.NewScanner(file)
  16. scanner.Split(bufio.ScanLines)
  17. for scanner.Scan() {
  18. lines = append(lines, scanner.Text())
  19. }
  20. file.Close()
  21. return lines
  22. }
  23. func main() {
  24. fmt.Println("Create script sql")
  25. ids := FileToList("idskill.txt")
  26. file, err := os.Create("idskill.sql")
  27. if err != nil {
  28. log.Panic(err)
  29. }
  30. for n, id := range ids {
  31. line := fmt.Sprintf("INSERT INTO Por_PortalSkillGroup (PortalSkillGroupId, Skill_DomainId, PortalSkillId) VALUES (%d, %s, %s);\n", n, "262144", id)
  32. fmt.Fprintf(file, line)
  33. }
  34. }