func CreateUser(username string) User { _, res, err := rreader.GetConnection().Query("INSERT INTO `users`(`name`) VALUES ('%s')", username) if err != nil { panic(err) } id := res.InsertId() return User{id: uint32(id), name: username} }
func importData(fileName string) { sql, err := ioutil.ReadFile("mysql.sql") if err != nil { panic(err) } _, _, err = rreader.GetConnection().Query(string(sql)) if err != nil { panic(err) } fmt.Println("Finished creating database.") user := CreateUser("nican") err = rreader.SQLImport(user.id, fileName) if err != nil { panic(err) } }