I have an python application which reads the python scripts and runs it and returns the values:
main.py
def Exec(id):
try:
connection = mysql.connector.connect(host='localhost',
user='root',
password='',
database='mydb')
# Fetch the python script from pythontbl table
sql_select_Query = "SELECT python FROM mydb.pythontbl WHERE id={}".format(id)
cursor = connection.cursor()
cursor.execute(sql_select_Query)
# get all records
script = cursor.fetchall()
# execute the python script with arguments
??
# return value should be saved in out
out= ???
print("output",out) ??
except mysql.connector.Error as e:
print("Error reading data from MySQL table", e)
finally:
if connection.is_connected():
connection.close()
cursor.close()
print("MySQL connection is closed")
how can I execute the python script which I fetched from my main and sending the arguments to script and get back the result ? I can not use import script.py as I am fetching the script through my main.py