Added setting of PGDATABASE in raptor function