I created a simple Flask-based API to the WorldDB on MySQL. They are two separate containers on the same network.
When I invoke the RESTful-API to list the citiies, using curl or SOAPUI, I get a 500 ERROR.
"
UnboundLocalError: local variable ‘cursor’ referenced before assignment
cityService | 172.18.0.1 - - [28/Nov/2022 23:37:36] “GET /listCities HTTP/1.1” 500 -
cityService | [2022-11-28 23:37:38,821] ERROR in app: Exception on /listCities [GET]
cityService | Traceback (most recent call last):
cityService | File “/usr/local/lib/python3.6/site-packages/flask/app.py”, line 2073, in wsgi_app
cityService | response = self.full_dispatch_request()
cityService | File “/usr/local/lib/python3.6/site-packages/flask/app.py”, line 1518, in full_dispatch_request
cityService | rv = self.handle_user_exception(e)
cityService | File “/usr/local/lib/python3.6/site-packages/flask/app.py”, line 1516, in full_dispatch_request
cityService | rv = self.dispatch_request()
cityService | File “/usr/local/lib/python3.6/site-packages/flask/app.py”, line 1502, in dispatch_request
cityService | return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
cityService | File “CityController.py”, line 55, in cities
cityService | cursor.close()
cityService | UnboundLocalError: local variable ‘cursor’ referenced before assignment
"
However, when I log into MySQL instance using MySQL-Workbench once using the ROOT-ID/PASSWORD,I can see the worldDB tables. Now I invoke the API again and I get the list of Cities just fine in the response.
" UnboundLocalError: local variable ‘cursor’ referenced before assignment
cityService | 172.18.0.1 - - [28/Nov/2022 23:37:39] “GET /listCities HTTP/1.1” 500 -
cityService | 172.18.0.1 - - [28/Nov/2022 23:41:12] “GET /listCities HTTP/1.1” 200 -"
Both containers are on my Windows-Docker-Desktop.
Any ideas please?
Thanks
Kind regards
-Ram