I would like to import the config file. it from sub-directory
├── config
│ ├── config.py
│ ├── database.ini
│ └── log.py
├── main.py
config.py
def function(file='database.ini',section='sql'):
return
database.ini
[sql]
host=1.1.1.1
user=admin
password=admin
database=sql
main.py
from config.config import function
def Run():
Test = function()
if __name__=="__main__":
Run()
The error warning look like
"Section sql not found in the database.ini file"
Now you see the structure of project. How to fix this?
def function(file=database.ini,section='sql'):would yieldNameError: name 'database' is not defined. There must be some code trying to open database.inifile='database.ini'Anyway, the error described in the questions suggests a different problem. Maybe this is helpful?def function(file='./config/database.ini',section='sql'):