def loadPlayer(index, name):
    clearPlayer(index)

    # fetch account details
    query = database.sendQuery("SELECT * FROM accounts WHERE username='%s';" % name)
    rows = query.fetchone()

    accountID = rows['id']
    Player[index].Login = rows['username']
    Player[index].Password = rows['password']

    # fetch character details
    query = database.sendQuery(accountID % "SELECT * FROM characters WHERE account_id=%i;")
    rows = query.fetchall()

    for i in range(0, MAX_CHARS):
        try:
            Player[index].char[i].name = rows[i]['name']
            Player[index].char[i].Class = rows[i]['class']
            Player[index].char[i].access = rows[i]['access']
            Player[index].char[i].sprite = rows[i]['sprite']
            Player[index].char[i].level = rows[i]['level']
            Player[index].char[i].exp = rows[i]['exp']
            Player[index].char[i].Map = rows[i]['map']
            Player[index].char[i].x = rows[i]['x']
            Player[index].char[i].y = rows[i]['y']
            Player[index].char[i].direction = rows[i]['direction']

            # set stats
            Player[index].char[i].stats[Stats.strength] = rows[i]['stats_strength']
            Player[index].char[i].stats[Stats.defense] = rows[i]['stats_defense']
            Player[index].char[i].stats[Stats.speed] = rows[i]['stats_speed']
            Player[index].char[i].stats[Stats.magic] = rows[i]['stats_magic']

            # set vitals
            Player[index].char[i].vitals[Vitals.hp] = rows[i]['vital_hp']
            Player[index].char[i].vitals[Vitals.mp] = rows[i]['vital_mp']
            Player[index].char[i].vitals[Vitals.sp] = rows[i]['vital_sp']

            # load equipment
            Player[index].char[i].equipment[Equipment.helmet] = rows[i]['helmet']
            Player[index].char[i].equipment[Equipment.armor] = rows[i]['armor']
            Player[index].char[i].equipment[Equipment.weapon] = rows[i]['weapon']
            Player[index].char[i].equipment[Equipment.shield] = rows[i]['shield']

            # load inventory
            charId = rows[i][0]

            invQuery = database.sendQuery("SELECT * FROM inventory WHERE character_id=%i;" % charId)
            invRow = invQuery.fetchall()

            for j in range(len(invRow)):
                try:
                    Player[index].char[i].inv[j].num = invRow[j]['item_id']-1
                    Player[index].char[i].inv[j].value = invRow[j]['value']
                    Player[index].char[i].inv[j].dur = invRow[j]['durability']

                except:
                    break

            # load spellbook
            spbQuery = database.sendQuery("SELECT * FROM spellbook WHERE character_id=%i;" % charId)
            spbRow = spbQuery.fetchall()

            for k in range(len(spbRow)):
                try:
                    setPlayerSpell(index, k, spbRow[k]['spellnum']-1)

                except:
                    break

        except:
            break
dataset/ETHPy150Open marcusmoller/pyorpg-server/src/database.py/loadPlayer/swapped operands of `%`