Пример #1
0
func PushScores(scores []interface{}) {
	SetLocale.SetLocale(SetLocale.LC_ALL, "de_DE")
	dsn := getDSN()
	db, err := sql.Open("oci8", dsn)
	check(err)

	defer db.Close()
	tx, err := db.Begin()
	check(err)
	stmt := PrepareStatement(tx, conf.Database.QueryOut)
	/*for _, score := range scores.Scores {
		ExecuteInsert(stmt, score)
	}*/
	fails_count := 0
	for _, score := range scores {
		if s, ok := score.(map[string]interface{}); ok {
			err = ExecuteScoreInsert(stmt, s)
			if err != nil {
				fails_count += 1
			}
		} else {
			pialog.Error("Not a valid score:\n", score)
		}
	}
	tx.Commit()
	pialog.Info("Score failures count:", fails_count)
}
Пример #2
0
func GetData() {
	SetLocale.SetLocale(SetLocale.LC_ALL, "de_DE")
	dsn := getDSN()
	db, err := sql.Open("oci8", dsn)
	check(err)
	defer db.Close()
	if err != nil {
		pialog.Error(err)
		return
	}
	SelectDBData(db, conf.Database.Query)
}
Пример #3
0
func main() {
	SetLocale.SetLocale(SetLocale.LC_ALL, "")

	// Parse command-line args
	flag.Parse()
	if *versionFlag {
		showVersion()
	} else if *helpFlag {
		usage()
	} else {
		// Compile symbol-matching regexp
		pattern, err := regexp.Compile(*symbol)
		if err != nil {
			panic(err)
		}

		// Process input
		args := flag.Args()
		if flag.NArg() == 0 {
			args = append(args, "-")
		}
		for i := range args {
			h := os.Stdin
			f := args[i]
			if f != "-" {
				h, err = os.Open(f)
				if err != nil {
					log.Fatal(err)
				}
			}

			// Read file into symbol table
			scanner := bufio.NewScanner(h)
			for scanner.Scan() {
				line := scanner.Text()
				if scanner.Err() != nil {
					log.Fatal(err)
				}
				for _, matches := range pattern.FindAllStringSubmatch(line, -1) {
					fmt.Println(string(matches[1]))
				}
			}
			h.Close()
		}
	}
}
Пример #4
0
func PushVarIMP(var_imps []interface{}) {
	SetLocale.SetLocale(SetLocale.LC_ALL, "de_DE")
	dsn := getDSN()
	db, err := sql.Open("oci8", dsn)
	check(err)
	defer db.Close()

	tx, err := db.Begin()
	check(err)
	stmt := PrepareStatement(tx, conf.Database.QueryOutImp)
	fails_count := 0
	for _, var_imp := range var_imps {
		if s, ok := var_imp.(map[string]interface{}); ok {
			err = ExecuteImpInsert(stmt, s)
			if err != nil {
				fails_count += 1
			}
		} else {
			pialog.Error("Not a valid var_imp:\n", var_imp)
		}
	}
	tx.Commit()
	pialog.Info("IMP failures count:", fails_count)
}