So I am using Flask to pass an input from html to a mysql db. However it only works for single characters ie can only input "5" and "a", however it cannot input "55" or "at". Here is my code.
__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 | |
+--------+----------+------+-----+---------+-------+