コード例 #1
0
func (a *run_tagger_action) setupConnPool() {
	a.connPool = make([]*db.Mysql, *a.workers)
	for i := 0; i < *a.workers; i++ {
		conn := new(db.Mysql)
		a.connPool[i] = conn.New(*a.dbUser, *a.dbPass, *a.dbName)
	}
}
コード例 #2
0
// Searches all tables unit it finds a match or no tables are left
func (t *Taggers) search_all_tables(token *string, conn *db.Mysql) int {
	escaped_token := sutils.EscapeAllQuotes(*token)
	names_q := "select * from names WHERE name = \"" + escaped_token + "\""
	dict_q := "select * from dict WHERE word = \"" + escaped_token + "\""
	geo_q := "select * from geo WHERE name = \"" + escaped_token + "\""

	if conn.Query(names_q) != nil {
		log.Tracef("%s found in names table", *token)
		return 1
	} else if conn.Query(dict_q) != nil {
		log.Tracef("%s found in dict table", *token)
		return 2
	} else if conn.Query(geo_q) != nil {
		log.Tracef("%s found in geo table", *token)
		return 3
	}
	log.Tracef("%s not found", *token)
	return -1
}