i've developed a APIful webapp using sqlite3 and flask framework with python, i have an external client that sends POST request, and it works correctly.
On my Windows environment the update query works correctly, when i try to execute all on my CentOS environment my query it return a syntax error, the following code is:
@app.route('/apis/rcvInfo', methods=['POST'])
def form_to_json():
if request.method == "POST":
table=request.form['table']
status=str(request.form['status'])
####query operations
nEntries = (sendQuery("SELECT COUNT (*) AS RowCnt FROM "+table))[0]
if (nEntries > 0 ):
sendQuery("UPDATE "+table+" SET status = "+status+", lastcheck=CURRENT_TIMESTAMP ORDER BY lastcheck DESC LIMIT 1")
else:
sendQuery("INSERT INTO "+table+" (status) VALUES ("+status+")")
db.get_db().commit()
return json.dumps({'success':True}), 200, {'ContentType':'application/json'} ```
def sendQuery(query):
cursor = db.get_db().cursor()
print (query)
cursor.execute(query)
records = cursor.fetchone()
return records
On my Windows environment the UPDATE statement work correctly, updating the first row.
But on my CentOS env i have the following error message:
sqlite3.OperationalError: near "ORDER": syntax error
The params (table, status) are correct.
ORDER BYis not used inUPDATEactions.