473,659 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_pro c as
select *
from dblink('myconne ction','select proname, prosrc from pg_proc')
as t1(proname name, prosrc text);

so I can do this ...

select * from myremote_pg_pro c 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('myconne ction','127.0.0 .1 port=5432 dbname=template 1
user=postgres password=mypass wd')

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

create view myremote_pg_pro c as
select *
from dblink('myconne ction','127.0.0 .1 port=5432 dbname=template 1
user=postgres password=mypass wd','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 10308
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 YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #2

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

Similar topics

1
8840
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 INTEGER AS ' DECLARE count INTEGER: myrec RECORD; BEGIN FOR myrec IN SELECT * FROM DBLINK(''select x,y from mytab'') as
0
509
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 mask the connection and make it easier to query. so I would do this ... create view myremote_pg_proc as select *
1
4169
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 the insertion of data in the current database throws an error, I want to rollback the dblink transaction, which should restore data in its original remote location. Thanks. Oleg
2
2327
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 AS SELECT * FROM dblink(' ... remote connection info ... ', 'SELECT id, title, title_idx FROM stuff')
2
7671
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 structures are the same) and tie the data back together again. After doing lots of reading it looks like dblink might be a great solution for this. After trying to insert dblink.sql into the database, I just get a series of errors:
1
2698
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 solution with dblink, embedding this command in a view, like this: create view inst as select * from dblink('host=pollux port=5432 dbname=cob_int user=his_int password=#integration#', ..... This solution is insecure, because login and password...
2
2788
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 integrity between the tables. Reading from Oracle articles, their referential integrity can be done using their dblink and triggers. What I'd like to ask is whether contrib/dblink is stable? Seeing dblink in a contrib directory does bring a doubt...
3
4931
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. However, I would like to replace the id and first_name in table1 to: 3 and 'nil' to insert into table2. INSERT INTO table2 SELECT * FROM dblink('dbname=db1', 'SELECT 3, nil, last_name FROM table1 WHERE id = 1000') AS t1(id integer, first_name...
1
2234
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
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.