pymysql.err.InternalError: Packet sequence number wrong - got 45 expected 0

Solution 1:

I think the reason was that you using multithread to connect to mysql at one time, the mysql server return the wrong response here.

Solution 2:

Okay, I figured it out.

I just needed to remove

cursorclass=pymysql.cursors.DictCursor

and now it works :)

Thanks everyone!