write into a postgres database