Next, we’ll update rows in the external database from the web app.
We need to write another function in our Server Module - this time we’ll do an UPDATE:
Python | Server
@anvil.server.callable
def update_item(item_id, name, quantity):
query = "UPDATE inventory SET name = %s, quantity = %s WHERE id = %s;"
with db_connection() as conn:
cur = conn.cursor()
cur.execute(query, [name, quantity, item_id])
conn.commit()
By