Disclosed are a nicotinic acid or isonicotinic acid compound and a use thereof. The compound is the compound shown in Formula I, or a pharmaceutically acceptable salt, ester or solvate thereof. Efficacy tests demonstrate that the nicotinic acid compound can inhibit botulinum toxin endopeptidase activity in vitro, and has a significant protective effect on mice poisoned with botulinum toxin. On this basis, the compound may be used to prepare a drug preventing and/or treating botulinum toxin exposure and/or poisoning.