Creating pg connection when needed