我正在做一个处理数据并返回数据框的小程序。现在它从DB中获取数据,所以我的函数直接指定了这样一种获取数据的方式(这意味着如果我想直接从我的PC中获取数据,我基本上必须重写函数)。因此,我的想法是,我需要指定在不同数据源之间轻松 "切换 "的能力。由于我不是一个程序员,我很难找到合适的方法。目前,我正在考虑创建额外的文件与功能处理数据从本地存储,但我卡在想如何链接到所需的文件。譬如
if data_from == "database":
go to the db_func.py file
if data_from == 'local_storage':
go to the local_func.py file
目前,我的应用有如下结构。
-app/\\-small functions #helper functions that are called to the DB_MODULE --DB_MODULE.py #module to process data with some "hardcode" --app.py #flask app part with routing
如何设置选项来指定从哪里使用数据?