Direct sewage discharge could cause copious numbers of serious and irreversible harm to the environment. This study investigated the impacts of treated and raw sewage on the river ecosystem. Through our analysis, sewage carried various nutrients into the river, leading to changes in the microbial community in the river and reducing the diversity and richness of bacteria. The relative abundances of Hydrogenophaga, Thauera, Planctomyces, Zoogloea, and Pseudomonas boosted from 0.25, 0.01, 0.00, 0.05, and 0.08% to 3.33, 3.43, 0.02, 6.28, and 2.69%, before and after raw sewage discharge, respectively. The gene abundance of pathogenic bacteria significantly increased after raw sewage discharge. For instance, the gene abundance of Vibrio, Helicobacter, Tuberculosis, and Staphylococcus augmented from 4055, 3797, 13,545, 33 reads at Site-1 to 23,556, 13,163, 19,887, 734 reads at Site-2, respectively. In addition, according to the redundancy analysis (RDA), the infectious pathogens were positively related to the environmental parameters, in which COD showed the highest positive correlation with Mycobacterium tuberculosis. Additionally, river self-purification may contribute to improving water quality and reducing pathogenicity. The outcomes of this study showed that direct discharge brought pathogens and changed microbial community structure of the river.