Thursday, 15 July 2010

database - How to write a Bash script which queries a PosgreSQL on another physical server -


I would like to create a bash script, I would say queryserver.sh, which is at IP at 1 2.168.2.1 on computer at, USERA With PASSA and PASSA password and computer user asks a Postgresql database on the computer. 192.160.10.1 user user and passwords with PASSB example.

In short, ComputerB has a PostgreSQL database table whose data is used to update the Postgresql table computerâ. The computer hosts a database used for a web application, while ComputerBank hosts backend number crunching functionality.

In Microsoft SQL Server, there is a concept of linked server, but I did not get the same concept on PostgreSQL / B>

There are several ways to solve this problem. psql can connect to remote hosts You can use ssh to remotely psql but since you were linked to MSSQL If you refer to the server, then PostgreSQL is most comparable.

  Certificate ComputerBrand Postgres_fdw option on foreign data wrap (host '1902.16.10.1', to access tables on Computer B as 'Port', on user A on Postgrass SQL instance of Computer A To allow, <5432 ', dbname' computerB '); Create user mapping for user server computer backup options (user 'USERB', password 'PASSB');  

Then you must use Create foreign table to use each table


No comments:

Post a Comment