You can make the changes to the script since Python scripts are not compiled. If you want to add logic to the script, you are going to have to learn Python. The script is retrieving data from a MySQL database and it is difficult to suggest implementations of logic if we do not know what kind of data the script is handling.