Connect to multiple databases #2784
-
Is it possible to connect to multiple databases ? I have a microservice architecture and each service connects to a seperate database in the same database server. Therefore I could have a connection string like so "postgres://user1:password1@localhost:5432/db1" AND Is this possible ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Not possible right now with a single instance. You'd have to run multiple postgrests. There was some discussion about mapping a different db connection using the Edit: #2798 Tangentially related, but libpq 16 is bringing load balancing with multiple dbs: https://mydbops.wordpress.com/2023/05/07/postgresql-16-brings-load-balancing-support-in-libpq-psql/ I wonder if libpq is really the right place to build connection pooling over. |
Beta Was this translation helpful? Give feedback.
-
@dattatre263 If one has controll over the DB configuration, by using a foreign data wrapper, one can access more "non-local" resources, and also indirectly (e.g. with views/matviews - since PG has no synonims) expose them with PostgREST. |
Beta Was this translation helpful? Give feedback.
Not possible right now with a single instance. You'd have to run multiple postgrests.
There was some discussion about mapping a different db connection using the
Host
header but just that.Edit: #2798
Tangentially related, but libpq 16 is bringing load balancing with multiple dbs: https://mydbops.wordpress.com/2023/05/07/postgresql-16-brings-load-balancing-support-in-libpq-psql/
I wonder if libpq is really the right place to build connection pooling over.