I suggest spending at least 2 nights in Hamburg. 3 days is a great amount of time to explore the city without a rush. If you have a bit more time, you can surely keep busy in Hamburg for about 5 days. I would not suggest staying for a week in Hamburg.