@app.route("/CreateAScheme",methods=['GET','POST'])
def CreateAScheme():
if request.method == 'POST':
userDetails = request.form
Scheme = userDetails['Scheme']
con = MySQL.connection.cursor()
con.execute("CREATE TABLE %s (id int NOT NULL AUTO_INCREMENT, Course varchar(255) NOT NULL, Year varchar(255), PRIMARY KEY(id));",(Scheme))
MySQL.connection.commit()
con.close()
flash("Succesfully Created")
return "Succesfully"
return render_template('index.html')
我收到一个错误“并非所有参数在字符串格式化期间都转换”
简单地将一个变量包装在括号中,就像您在
(Scheme)
中所做的那样,没有任何作用.execute()
需要一个参数元组,不管它是否只是一个1元组,即(Scheme,)
:“只需使用常规%插值”
谢谢@AKX
相关问题 更多 >
编程相关推荐