使用flask从html输入mysql;仅接受单字符输入

使用flask从html输入mysql;仅接受单字符输入,html,mysql,flask,Html,Mysql,Flask,因此,我使用Flask将输入从html传递到mysql数据库。但是,它只适用于单个字符,即只能输入“5”和“a”,但不能输入“55”或“at”。这是我的密码 __init__.py : @app.route('/statistics',methods=['GET','POST']) def statsinput(): if request.method=='GET': return render_template("statsinput.html"

因此,我使用Flask将输入从html传递到mysql数据库。但是,它只适用于单个字符,即只能输入“5”和“a”,但不能输入“55”或“at”。这是我的密码

__init__.py :
@app.route('/statistics',methods=['GET','POST'])
def statsinput():
        if request.method=='GET':
                return render_template("statsinput.html")
        else:
                first_name=(request.form['fname'])
                c, conn = connection()
                query="INSERT INTO test VALUES(%s)"
                c.execute(query,first_name)
                conn.commit()
                return ('working')

statsinput.html:
<!DOCTYPE html>
<html>
   <body>
    <form method="POST">
      First name: <input type="text" name="fname"><br>
      <input type="submit" value="Submit">
    </form>
  </body>
</html>

Here is the description for my mysql table:
mysql> DESCRIBE test;
 +--------+----------+------+-----+---------+-------+
| Field  | Type     | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| ticker | char(50) | YES  |     | NULL    |       |
+--------+----------+------+-----+---------+-------+
\uuuu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
@app.route('/statistics',methods=['GET','POST'])
def statinsput():
if request.method==“GET”:
返回渲染模板(“statinsput.html”)
其他:
first_name=(request.form['fname'])
c、 conn=连接()
query=“插入测试值(%s)”
c、 执行(查询,第一个名称)
康涅狄格州提交
返回(‘工作’)
statinsput.html:
名字:
以下是我的mysql表的说明: mysql>描述测试; +--------+----------+------+-----+---------+-------+ |字段|类型|空|键|默认|额外| +--------+----------+------+-----+---------+-------+ |股票代码|字符(50)|是| |空|| +--------+----------+------+-----+---------+-------+
在查询字符串中正确插入

query="INSERT INTO test VALUES({})".format(first_name)
c.execute(query)

@老兄,这是行不通的。不幸的是,我不知道这有什么问题;我试着按照这个()