Here is the full traceback:
Traceback (most recent call last):
...
File "C:\Users\rafin\Dyna\updews-pycodes\dynadb\db.py", line 251, in read
db, cur = connect(host=host, connection=connection,
TypeError: cannot unpack non-iterable bool object
Here is the whole db.py script which is the source of the TypeError if it helps
Please tell me if there's any additional information that I could provide.
CodePudding user response:
This error comes from doing the equivalent of the following:
x, y = True
TypeError: cannot unpack non-iterable bool object
On the right-hand side of the assignment, you have a boolean, True
. The interpreter has no way to split that up into 2 values as required by the left-hand side of the assignment, so it gives an error.
Your connect
function returns a Connection object and a Cursor cursor object when connection succeeds, but returns the boolean value False when connection fails, leading you to the above error.
It's generally considered a design problem to return different shapes of results from a function. Raise an exception on failure or return the same shape on all code paths, say (True, connection, cursor) on success and (False, None, None) on failure.
Good luck! :)