Changed from pymysql to MySQLdb