updated to be compatible with pymysql