Provided are a β-lactamase inhibitor as shown in formula (I), or an ester, a stereoisomer, a pharmaceutically acceptable salt thereof and a preparation method therefor, and a pharmaceutical composition comprising the β-lactamase inhibitor as shown in formula (I), or an ester, a stereoisomer and a pharmaceutically acceptable salt thereof; and a method for treating diseases caused by bacterial infection, which includes administering the β-lactamase inhibitor as shown in formula (I), or an ester, a stereoisomer and a pharmaceutically acceptable salt thereof to patients or subjects in need.