Ping database before trying to store

This will hopefully bail out if the database went down between two
callbacks. Since I don't want to manage all possible errors in code, we
just let systemd restart the script. YOLO.