Oct-06-2021, 04:33 PM
(Oct-06-2021, 05:21 AM)zazas321 Wrote:(Oct-05-2021, 03:11 PM)tomtom Wrote: I used to have similar problem with mysql database. when I used with a windows server, I search and search but didn't find a solution on it, so what I did was to create a function that connect to the mysql db and call it any time I want to make a query to the dp. That is how I solved my own
these is the example:
def connect_to_db(): # function connect to database return mysql.connector.connect(host="localhost", user="root", passwd="", database="lookup_bot")
Yes, that is what I did but have not find any bug on it
Then I do this whenever I want to make a query:
mydp = connect_to_db() my_cursor = mydp.cursor(buffered=True)
Thanks for the reply. Can you explain what the code does? Do you make a new connection everytime you want to perform a query? If so, that does not seem like a good solution?
The problem for me is that after 1 hour of idling, the connection is still active and I can see the connection on the processlist as I have shown before. Even though the connection is still active, it wont let me do any queries.
As a temporary solution, I have some function that is being executed every 10 minutes which performs some query to my database to ensure that the connection does not idle for too long. That seems to work however that is not an optimal solution