I’ve seen to approaches which I’m going to post in the comments to see which one is considered best. Feel free to suggest others.
I’ve seen to approaches which I’m going to post in the comments to see which one is considered best. Feel free to suggest others.
This, but, with DatabaseConnection being a singleton, and preventing multiple enter clauses.
You can ensure it’s a singleton by modifying how a new object is built, by overriding the new dunder method. If an instance exists, return that, otherwise create a new one.