I have a question

Can you have sex while having a UTI and being pregnant ?? Or is it not safe