Heat the olive oil in a pan over medium heat. Slice the onions in half rings and fry with garlic for 2 minutes.
Put all the spices and herbs in the pan and fry until the garlic starts to turn golden brown, and then add the tomatoes and sugar cut in half. Mix well. Reduce heat and continue cooking.
Boil spaghetti in salted water. Drain the pasta and put it in the sauce. Add cheese and chopped basil to the paste. Pasta with tomatoes is ready, mix well and serve.