dbtest1.py :<br>
import pymysql.connector<br>
dbCon = pymysql.connector.connect(host='...', database='...', user='...', password='...')<br>
cursor = dbCon.cursor()<br>
cursor.execute("INSERT INTO cm_person (name) VALUES ('고길송')")<br>
dbCon.commit()
views.py include...
def datatest(request):<br>
subprocess.call(['python', 'dbtest3.py'])<br>
return HttpResponse('Call python...')
Error message;
ModuleNotFoundError: No module named 'pymysql'
Did I miss something? or is there any other methods? Thank you.
If you are using virtual environments, depending how you run your script, 'python'
might refer to the system Python. Using sys.executable
instead of 'python'
might help.
Note that if you are using WSGI, sys.executable
is probably not set correctly, so you might want to set it explicitly in your WSGI entry point script.