PyMySQL: Connection was aborted by the software in your host machine

Question:

I executed the below code and it shows this error.

Here is the code snippet.

import pymysql
mydb = pymysql.connect(
    database = "q11",
    user = "111",
    password = "11111",
    host = "localhost"
)

The error I am getting is:

pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None))")```
Asked By: Hasan Vajdi

||

Answers:

I have a problem when I connect to my MySQL database and after a long time, it hangs and my code is not getting anything from the database.
I found a solution to my problem and put the DB connection in the main message handler

Answered By: Hasan Vajdi
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.