473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

dblink questions


What's the best way to create a connection with dblink with persisted
connections for web applications?

For example:

I want to have a view that links to a table in another pg database so I
can mask the connection and make it easier to query.

so I would do this ...

create view myremote_pg_proc as
select *
from dblink('myconnection','select proname, prosrc from pg_proc')
as t1(proname name, prosrc text);

so I can do this ...

select * from myremote_pg_proc where proname like 'bytea%';

I understand that a connection can be made by dblink_connect(text
connstr) and
dblink_connect(text connname, text connstr), but how do you suggest
making the first connection from a web application?

select dblink('myconnection','127.0.0.1 port=5432 dbname=template1
user=postgres password=mypasswd')

Do you suggestion not using the persistent connection? and do this?

create view myremote_pg_proc as
select *
from dblink('myconnection','127.0.0.1 port=5432 dbname=template1
user=postgres password=mypasswd','select proname, prosrc from pg_proc')
as t1(proname name, prosrc text);

Thanks a Bunch,

Brian

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
1 10286
Brian Maguire wrote:
What's the best way to create a connection with dblink with persisted
connections for web applications?


It all depends on how you intend to use the dblink connections.

If your web page connects to Postgres, issues a single query using
dblink (via a view or whatever), and then completes, you don't need a
persistent dblink connection -- just use the explicit connection syntax.

If, on the other hand, your web page connects to Postgres, issues
several queries using dblink (via a view or whatever), and then
completes, it would make sense to use a persistent dblink connection. In
that case, execute dblink_connect() before you execute your queries. Use
named persistent connections if you need more than one, anonymous otherwise.

HTH,

Joe
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Clive Page | last post by:
What I'd like to do is use dblink to extract a few rows from a remote database and manipulate these within a function in pl/pgsql. Something like this: CREATE OR REPLACE FUNCTION find() RETURNS...
0
by: Brian Maguire | last post by:
What's the best way to create a connection with dblink with persisted connections with web applications? For example: I want to have a view that links to a table in another pg database so I can...
1
by: Oleg Lebedev | last post by:
Is there a way to rollback a dblink transaction? Say, I delete some data from the remote database, but I don't want this to be visible untill the data is inserted in the current database. And if...
2
by: Mark Gibson | last post by:
Hello, I've been experimenting with dblink recently, and have encountered some limitations I'd like to discuss. I've been trying to create views of remote tables, like so: CREATE VIEW stuff...
2
by: Sam Masiello | last post by:
Hello all! I am rather stuck and am hoping someone can help. I am working on a project where users need to be able to send one query which will hit databases on multiple hosts (the database...
1
by: Kreißl, Karsten | last post by:
Hello, we want use dblink to connect several databases in a client/server environment. Connection from local users to the remote databases should be possible only for privileged users. We tried a...
2
by: Jim Worke | last post by:
Hi list, My boss would like to convert from MySQL to PostgreSQL, but there are a few things that hold us back. We'd like to have the databases in several physical servers, with referential...
3
by: stephcsh | last post by:
Hi, I wanted to copy a data from table1 in db1 to table2 in db2, which has the same structure, with the PosgreSQL dblink funtion. The fields for both the tables are: id, first_name, last_name. ...
1
by: dsslim | last post by:
Hi, Oracle instance A has a dblink to DB2 DB. Oracle instance B, which resides on the another machine wants to access the DB2 via Oracle instance A's dblink. Possible ? TIA !
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.