Connect two Postgres database from a single project

How can I connect two different Postgres database from a single project and do some transformations?