I have a module (db.py) that loads data from different types of databases (sqlite, mysql, etc.), the module contains the db_loader class and subclasses (sqlite_loader, mysql_loader) that inherit it.
The type of database used is in a separate parameter file,
How does the user return the correct object?
ie how can I do:
loader = db.loader()
Am I using a method called loader in the db.py module, or is there a more elegant way that a class can select its own subclass based on a parameter? Is there a standard way to do this?
source share