Cook the spaghetti al dente according to the instructions on the packet.
Meanwhile, dice the onion, finely chop the garlic cloves and either cut the zucchini into small pieces or roughly grate.
Heat the oil, add the onion and garlic and sweat until translucent. Now add the zucchini and cook for a while. Deglaze with the pizza tomatoes and season with salt, pepper, sugar, rosemary and thyme. Let simmer for approx. 5-10 minutes. Now add the ricotta and season again if necessary.
Serve with the spaghetti and sprinkle with pecorino or parmesan.