0

I'm using flask to create my api and testing select query... it works fine in first select, but if i change records manualy, my select still returning old values...

My endpoint code:

def checkAuth():
    cursor = conn.cursor()
    data = request.get_json()
    email = data['email']
    passw = data['passw']
    query = f"SELECT COUNT(id), email, passw, stat FROM users WHERE email = '{email}' AND passw = '{passw}'"
    cursor.execute(query)
    res = cursor.fetchone()
    cursor.close()
    rows_count = res[0]
    if rows_count < 1:
        return "Error"
    return jsonify(res)

First it return "[ 1, "test", "$2y$10fa1841ee3e15a782d0371096caffeada2VXh/Y5/afFgRyYWenuuTfrsK", 1 ] "

But if i change stat to 0 and request this endpoint again, it return the same string, withou changint the last index value to 0... it only changes if i close my api and open again...

Antharaz
  • 33
  • 7
  • 1
    You need to call `commit()` or `rollback()` on the connection so that it can see the latest changes, or connect in autocommit mode - see the linked duplicate for more details. – snakecharmerb Nov 22 '22 at 12:58
  • https://stackoverflow.com/a/23683656/995052 – Kris Nov 22 '22 at 12:59

0 Answers0