Since your code only runs to
print('k')
please double check your connection parameter. Also check, if you created a database with you specified name. I was able to run your code just fine after setting up Python and a MySQL-server.