From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Mike Christensen <mike(at)kitchenpc(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Is there a way to avoid hard coding database connection info into views? |
Date: | 2012-05-15 19:59:07 |
Message-ID: | CAHyXU0zrEkbHy-pwuEzfZmOHk=S02YOv9vytKFU+9gS7jjqv1w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, May 15, 2012 at 2:51 PM, Mike Christensen <mike(at)kitchenpc(dot)com> wrote:
> Thanks!
>
> I've never done that in PG before, but I've used named connections
> with Oracle. Is it the same sort of deal? There's a file on the disk
> somewhere with the connection info? Either way, I'm sure it's a RTFM
> thing so I'll look into it.
yeah, there's a good example in the docs here:
http://www.postgresql.org/docs/9.1/static/contrib-dblink-connect.html
btw, if you have a structure in test that matches production, then you
can use a composite type trick to avoid having to specify fields as
long as you keep those structures in sync (which you have to do
anyways). try:
select (u).* from dblink(
'hostaddr=123.123.123.123 dbname=ProductionDB user=ROUser
password=secret',
'select u from users u') as t1(u users);
it should work as long as users exists on both sides and has exactly
the same structure. using that method it's trivial to make a dblink
wrapper that could query any table but you couldn't wrap it into a
single view obviously.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Christensen | 2012-05-15 20:16:29 | Re: Is there a way to avoid hard coding database connection info into views? |
Previous Message | Mike Christensen | 2012-05-15 19:51:54 | Re: Is there a way to avoid hard coding database connection info into views? |