from Consultas_SQL.conexion import get_connection


def updateById(id: str, data: dict):
    """
    example:
        updateById("123", {"name": "New Quote Name", "amount": 1000})
    """
    conn = get_connection()
    cursor = conn.cursor()
    set_clause = ", ".join([f"{key} = %s" for key in data.keys()])
    cursor.execute(f"UPDATE Quotes SET {set_clause} WHERE id = %s", (*data.values(), id))
    conn.commit()
    cursor.close()
    conn.close()