I am trying to make a simple program using flask + mysql. I just receive two arguments in a POST and write to the database:
@app.route('/upd',methods=['POST'])
def upd():
_lat = request.form['lat']
_lng = request.form['lng']
cur = mysql.connection.cursor()
cur.execute('insert into locations(lat,lng) values (?,?)',(_lat,_lng,))
cur.commit()
return jsonify(request.form)
The problem is that when i try to post the data from the client , i am getting:
ProgrammingError: not all arguments converted during string formatting
127.0.0.1 - - [28/Apr/2018 23:46:14] "POST /upd HTTP/1.1" 500 -
If i comment the SQL statement, the client will receive the output of jsonify which looks correct:
{
"lat": "3.2001",
"lng": "-11.45465"
}