Embedded report app flask

I have an application with Flask where I embed reports, I get a list of reports (I save the id in a database) and later it makes me embedded the one I select, locally I don’t get any errors and it shows me the id value of the selected report , when I upload the application to my website, then it is as if the ids remain in cache for a while because I select 1 but it shows me another, normally the previous one seen, as if something remained in cache and it reloaded what was before .
Has it happened to anyone?

If you select a particular report id (through your web API, I assume) and always get back the report for id - 1, my guess is that you have some off-by-one error somewhere.

I don’t quite understand what you mean. I’ll give you code so you can understand how I get the id of the report.

I told you, locally it loads the report id correctly, so I don’t think it’s a matter of incorrect code.

Check where I get the report id

def obtener_report_por_id_user2(db,usuario,id_repor):
    with db.connection.cursor() as cursor:
        reports = []
        result = cursor.execute("""SELECT report FROM reports_workspace WHERE id_user = %s AND id = %s """, (usuario,id_repor))
       WHERE id = '{}'""".format(id_repor))
        reports = cursor.fetchone()
    return reports

which I later pass it to my template.

def view_repor(id_repor):
    repor = obtener_report_por_id_user2(db,usuario,id_repor)

    return render_template("view_repor.html", repor=repor)

Something must have gone wrong in your posting, since that snippet is not valid Python code.

(Btw - what kind of DB and what kind of python wrapper are you using? Postgress with SqlAlchemy?
If you’re using SqlAlchemy - don’t you find using the ORM is easier to maintain/cleaner? See: ORM Quick Start — SQLAlchemy 2.0 Documentation)

What do you mean it’s not valid? There is some line missing that I see was not copied correctly but the code works.
I am not using sqlalchemy, I declare variables like this

connection variables

app.config["MYSQL_HOST"] = "xxxxx"
app.config["MYSQL_USER"] = "xxxxx"
app.config["MYSQL_PASSWORD"] = "xxxxx"
app.config["MYSQL_DB"] = "xxxxx"
db = MySQL(app)

And I use that in functions.

The code in the first code block you posted looks garbled and it’s unclear to me what is intended.
Also not clear what you mean by “locally”. Do you mean: running on a localhost with a local DB (so an entirely different DB)? It’s not clear to me if you can draw strong conclusions from that.
Anyway - one way to see if some caching is involved may be: Dump all headers of your requests and responses and inspect those. Or: Add some simple logging to the Flask code and double-check that the right id values are being requested (and that actually two calls are being made on the backend).