Bactrim for UTI and pregnancy

Not looking for judgement. New mom here, expecting our first baby in May. I'm 6 weeks 5 days.. and my doctor just called today with results from my bloodwork. I have a UTI (go figure). I haven't had obvious symptoms of a UTI.. but she explained with the bacteria in my system the only antibiotic she could prescribe me that would totally rid me of my UTI is Bactrim. I picked it up today at pharmacy and it clearly says on warning label to not take while pregnant because it's class D and linked directly to developement abnormalities... so of course I don't want to harm my baby. I also don't want it to reach my kidney because then I have a much bigger problem. I don't know what to do. I feel overwhelmed by everything and I don't want to do anything that will harm the baby as well. I am already considered high risk already because I have hypothyroidism. Help!! :(