It is recommended that when asking questions, try to post the error message and the error code instead of taking screenshots.
The error message indicates that the mysql connection is lost.
search_cursor = search_conn.cursor()
Seeing that your list_related function did not pass in the search_conn parameter, did you define it as a global variable? If this is the case, it is because mysql has a default connect_timeout time, which will automatically close the connection once it is exceeded.
You can try the following two methods:
Set the connect_timeout time when creating a connection and set it longer.
Every time you operate the database, a connection is established and closed after the operation is completed.
Judging from your SQL statement, it is not well written. You need to study it carefully and make full use of indexes or third-party word segmentation systems
It is recommended that when asking questions, try to post the error message and the error code instead of taking screenshots.
The error message indicates that the mysql connection is lost.
Seeing that your list_related function did not pass in the search_conn parameter, did you define it as a global variable? If this is the case, it is because mysql has a default connect_timeout time, which will automatically close the connection once it is exceeded.
You can try the following two methods:
Set the connect_timeout time when creating a connection and set it longer.
Every time you operate the database, a connection is established and closed after the operation is completed.
Judging from your SQL statement, it is not well written. You need to study it carefully and make full use of indexes or third-party word segmentation systems
Django’s ORM is not easy to use?