Prescriptions, orders, and records, required by this subchapter, and stocks of narcotic drugs, shall be open for inspection only to federal, state, county, and municipal officers, whose duty it is to enforce the laws of this state or of the United States relating to narcotic drugs. No officer having knowledge by virtue of his office of any such prescription, order, or record shall divulge such knowledge, except in connection with a prosecution or proceeding in court or before a licensing or registration board or officer, to which prosecution or proceeding the person to whom such prescriptions, orders, or records relate is a party.