473,394 Members | 1,642 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,394 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 10288
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.