Taking any medication during pregnancy or breastfeeding would affect the baby as well. Thus, before taking any kind of sleeping pills, discuss with your doctor or healthcare provider.