mardi 20 octobre 2020

What is the proper way to implement the DAO pattern in Python

I'm fairly new to Python, and I'm working on a mid-size project that involves persisting some relatively simple objects. I'd like to play around with different storage methods -- SQL DB, NoSQL DB, a plain old JSON file on disk (useful for debugging), etc. Additionally, I know that I'll have to read and write CSV/Excel files at some point. What is the proper Python-y design pattern for this problem ?

If I were writing this in an OOP language, I'd create a DAO interface, and implement it multiple times, once for each storage method; then I'd instantiate these implementations or maybe even use some form of IoC to juggle them. However, I understand that this isn't a very Python-y way to do things, so I'm looking for better alternatives.

Aucun commentaire:

Enregistrer un commentaire