Let’s play a bit with the framework !
We are connected to the sandbox of a user.
We reset the table log :
delete from log;
We connect to the kernel :
select public.connect_kernel('18.104.22.168','micheld', 'password')
We connect a database :
select public.connect_database('contacts','micheld', 'password')
We verify that the foreign servers are initialized :
We must obtain something like that (mgr is the owner of the databases) :
We map the tables of the database database in the sandbox.
and we go with pgAdmin on the tab Foreign tables to verify that everything works fine.
We disconnect now from the corporate database and all foreign tables will be removed from the sandbox :
We verify in the log table that everything is OK :
select * from log order by 1 desc
That’s simple ! Those functions must be called from the front end applications with the appropriate syntax.
In fact, the function attach_database could be called directly by the function connect_database.