Connect to the database when activating the relays