coffeewithalex@lemmy.worldtoPython@programming.dev•What's the best approach to avoid defining sqlite3 conn and cursor in many different functions?
1·
1 year agoThis, 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.
On Linux, I’d just build my own Python binaries and make them available. But you can also use pyenv for the same thing if you’re ok with it.
Then, using poetry, I have different projects with isolated environments.