Generally, pepper spray that is used for humans are not very effective against K9 dogs, who are trained and used to tear gas used by military and law enforcement. Therefore, Germany since 1950's produces pepper spray intended for dogs only. It is widely used in Europe, and if it can be purchased in USA. However, the point is to spray the dog and run, because it will disorient the beast for 30s to 90s. Standing there and expecting that dog will give up after spray, will not do anything good.
Stabbing a dog is hard, he must be very close, and there is no guarantee he would not get even more aggressive. Shooting dog randomly just because he is running toward you is not easy and also bring you in conflict with law. If dog is already biting your calves, there is a good chance you will shoot your own leg than hitting a dog. You can ask any LE who will tell you how hard is to shoot dog on your leg.
The best way avoiding this scenario is not get any strange animal close by. Not every animal is friendly and wants to be petted.