I am using python with a mysql db.
I have a table in that db storing names of functions to be run.
I would like to also add a possibility to store variables in the table, retrieve them on the fly and pass them into the function.
However when stored in the db, the arguments are strings, and I don't know how to convert them to variable names to pass to the function.
For instance lets consider the following example where the table contains:
module function arguments (<--columns names)
indicators scrape_web datapoints
Let's say that I retrieve the data with a mysql lib and save it in a dict such as:
script:{'module': 'indicators',
'function': 'scrape_web',
'arguments': 'datapoints'}
I can retrieve the module and function name, and run the function without arguments like that :
module = __import__(script['module'])
func = getattr(module, script['function'])
func()
But what if i want to pass the arguments into the function so that the function run func(datapoints)
func(script['arguments'])
Obviously doesn't work.
All help greatly appreciated.
func('datapoints')orfunc(datapoints)(wheredatapointsis a variable containing some data)?datapointssupposed to be found in?func(datapoints)funcglobals()['datapoints']