def go_add (request):
if request.method == "POST":
class_name = request.POST.get("cname")
conn=pymysql.connect(host="192.168.2.130",user="root",password="root",database="test",charset="utf8")
cursor=conn.cursor(cursor=pymysql.cursors.DictCursor)
sql="insert into user(user) values(%s);"
-sharpexecutemany
cursor.execute(sql,class_name)
-sharp
conn.commit()
conn.close()
cursor.close()
return redirect("../index/")
return render(request, "add.html")
< H1 > this is a routine operation, but each time a new function is written, the database is linked < / H1 >