I know I'm not the first one to bring this up, but... I've read every other topic that deals with this error, tried EVERYTHING for 2 weeks now, and I can't even get a simple database query to work... I've been working with pythonanywhere for years now. I even got a paid account (not this one), but I think my only option is to go to Heroku :-(
Here is my problem :
I have initialized a database. Everything works fine... I can create tables, insert data, read data, etc. But... whenever the (Flask) website is not used, after 5 minutes, some time-out trigger gets fired (one that I can't change, I tried, I don't have the rights for that) and this is what I'm getting for bloody 2 weeks now:
Then the error log says :
2020-10-14 09:07:37,515: Exception on /admin [GET] Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/usr/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/usr/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functionsrule.endpoint File "/home/Exodus2200/mysite/flask_app.py", line 143, in admin users = read_user_data(cur) File "/home/Exodus2200/mysite/database.py", line 76, in read_user_data cur.execute('''SELECT * FROM Users''') File "/usr/lib/python3.8/site-packages/MySQLdb/cursors.py", line 209, in execute res = self._query(query) File "/usr/lib/python3.8/site-packages/MySQLdb/cursors.py", line 315, in _query db.query(q) File "/usr/lib/python3.8/site-packages/MySQLdb/connections.py", line 226, in query _mysql.connection.query(self, query) MySQLdb._exceptions.OperationalError: (2013, 'Lost connection to MySQL server during query')
I've tried EVERYTHING to make this error go away:
- Closing all connections, then reestablish a new connection before accessing the DB
- Closing the cursor, then reestablish a new connection before accessing the DB
- etc. etc.
It's the most frustrating situation I've ever encountered since I started working with Pythonanywhere 5 years ago.