Storing and iterating Lua arrays in MySQL table

Hello,

I’m having an issue with selecting and iterating through data in a database and was wondering if anyone could point me in the right direction.

I want to select a list of weapons that the player has from the database and give these weapons to the player.

The best way of I could think of to do this was to store the list in a format similar to what Lua expects for an array, and to then select this list, and iterate through each item in the list adding each weapon to the player each time.

This isn’t working out as planned though. When I print the result it returns the list of weapons I have stored in the database, but when I iterate through the list, only the knife is given the player.

Does anyone know a better way - correction, a way that actually works - to accomplish this?

The list as written in the database:

"WEAPON_KNIFE", "WEAPON_PISTOL50", "WEAPON_RPG"

server.lua:

RegisterServerEvent('GetPlayerWeapons')
AddEventHandler('GetPlayerWeapons', function()
        MySQL.Async.fetchAll('SELECT * FROM characters', {}, function(characters)
            local charweapons = (characters[1].weapons)
            TriggerClientEvent('SetCharacterWeapons', -1, charweapons)
        end)
end)

client.lua:

RegisterNetEvent('SetCharacterWeapons')
AddEventHandler('SetCharacterWeapons', function(charweapons)
    weapons = { charweapons }

   for i, name in ipairs(charweapons) do
       GiveWeaponToPed(GetPlayerPed(-1), name, 100, false, false)
        print(name)
    end
end)