Bring a large pot of salted water to a boil.
Add spaghetti and cook according to package instructions until al dente.
While pasta cooks, heat olive oil in a pan over medium heat.
Add chopped onion and sauté until translucent.
Stir in minced garlic and cook for another minute.
Pour in crushed tomatoes and stir well.
Add sugar, salt, and pepper; let simmer for 10 minutes.
Drain the pasta and reserve a bit of pasta water.
Combine pasta with the sauce, adding reserved water if needed for consistency.
Serve hot, garnished with fresh basil and Parmesan cheese.