DB connection implemented according to pg snippet