I'm using mysql.connector with Django. The credentials are working fine, since I'm able to connect occasionally. I suspect that it might be due to the number of connections at that moment. I do not wish to make a new connection and cursor everytime i call a function. Kindly advise. Thanks
2022-03-02 13:03:44,067: OK: /api/borrowed_shares/amc/ Traceback (most recent call last): File "/home/stocksera/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/stocksera/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, callback_args, callback_kwargs) File "./api/views.py", line 547, in borrowed_shares df = pd.read_sql_query(f"SELECT * FROM shares_available WHERE ticker='{ticker_selected.upper()}' " File "/home/stocksera/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/pandas/io/sql.py", line 436, in read_sql_query return pandas_sql.read_query( File "/home/stocksera/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/pandas/io/sql.py", line 2116, in read_query cursor = self.execute(args) File "/home/stocksera/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/pandas/io/sql.py", line 2054, in execute cur = self.con.cursor() File "/home/stocksera/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 578, in cursor raise errors.OperationalError("MySQL Connection not available.") mysql.connector.errors.OperationalError: MySQL Connection not available.