package main import ( "fmt" "log" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" ) func main() { var config Config config.GetConfig() config.DbSchema = fmt.Sprintf("CREATE TABLE IF NOT EXISTS `%s` (`id` int(8) NOT NULL AUTO_INCREMENT, `qrz` varchar(25) NOT NULL, `name` varchar(25) DEFAULT NULL, `address` varchar(50) DEFAULT NULL, `city` varchar(50) DEFAULT NULL, `zipcode` varchar(5) DEFAULT NULL, `dept` varchar(50) DEFAULT NULL, `country` varchar(25) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `qrz` (`qrz`,`name`,`city`,`dept`) USING BTREE, KEY `test` (`country`), FULLTEXT KEY `city` (`city`), FULLTEXT KEY `dept` (`dept`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;", config.DbTable) config.DbInsertStatement = "INSERT IGNORE INTO %s (qrz,name,city,dept,country) VALUES ('%s','%s','%s','%s','%s');" db, err := sqlx.Connect("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s", config.DbUsername, config.DbPassword, config.DbHostname, config.DbName)) if err != nil { log.Fatalln(err) } bodyString, err := GetBody(config) if err != nil { log.Fatalln(err) } frsPeople, err := GetFrsEntries(config, bodyString) if err != nil { log.Fatalln(err) } _, err = db.Exec(config.DbSchema) if err != nil { log.Fatalln(err) } err = InsertFrsEntryToDB(config, *db, frsPeople) if err != nil { log.Fatalln(err) } }