To address the original error:
NotImplementedError: Database objects do not implement truth value testing or bool(). Please compare with None instead: database is not None
This was an intentional minor breaking change we made in PyMongo 4.0 described here:
Database.__bool__raises NotImplementedError¶
Database now raises an error upon evaluating as a Boolean. Code like this:
if database:
Can be changed to this:
if database is not None:
You must now explicitly compare with None.
The full trackback of the exception will show which line needs to be changed.