optimizing inventory.py script (fewer mysql querys, more speed)