Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import server list between pgadmin 4

Tags:

pgadmin

How to import/export server lists between pgadmin 4.2 between computer (in Windows)?

I found some links for pgadmin 3 regarding registry. Would that be same for 4 too.

pgAdmin - Sharing DB Connection Definitions

like image 802
snowrock Avatar asked Dec 08 '17 16:12

snowrock


People also ask

How do I join another server in pgAdmin 4?

To access the dialog, right click on the server name in the pgAdmin tree control, and select Connect Server… from the context menu. Provide authentication information for the selected server: Use the Password field to provide the password of the user that is associated with the defined server.

How do you import Export database in pgAdmin 4?

Step 1: Visit your schema section and select the table you wish to export. Step 2: Right-click on the table name to show up the available options. Step 3: Select the “Import/Export” option. When you click on it, the export data pgAdmin window will appear.

How do I add a Postgres server to pgAdmin?

Using a GUI Run pgAdmin. Right-click on the item Servers , select Create -> Server and provide the connection to your PostgreSQL instance set up in step 1. In the default PostgreSQL setup, the administrator user is postgres with an empty password. In the connection tab be sure to have the host set to localhost .


2 Answers

According to https://stackoverflow.com/a/45823367/89346, configuration data seems to be available in C:\Users\{Your_User}\AppData\Roaming\pgAdmin. You may try to copy the pgAdmin directory across different machines

like image 161
shantanoo Avatar answered Oct 15 '22 23:10

shantanoo


Documentation exists for this, here: Exporting and importing Servers

When you install pgAdmin4 on Windows, e.g. C:\Program Files (x86)\pgAdmin 4\v4 for version pgAdmin4 v4.2 in my case, there is a subfolder named venv which hosts another Scripts subfolder in which is stored Python Virtual Environment mentioned in documentation.

This is the python.exe that we can use to dump the servers list. Open a command prompt (Win + R, cmd), and browse to this Scripts subdirectory

cd "C:\Program Files (x86)\pgAdmin 4\v4\venv\Scripts"

The command I used to create the dump is:

python.exe "C:\Program Files (x86)\pgAdmin 4\v4\web\setup.py" --dump-servers D:\dump\pgAdmin4_servers_list.json

If successful, message stating number of servers descriptions dumped will be displayed. In my case:

Configuration for 43 servers dumped to D:\dump\pgAdmin4_servers_list.json.

Then, copy the JSON file to the new computer and, using a command prompt, browse to the same subdirectory as before:

cd "C:\Program Files (x86)\pgAdmin 4\v4\venv\Scripts"

Before import, make sure pgAdmin4 server is shutdown. Now you can import the JSON file content (E: is my flash drive letter):

python.exe "C:\Program Files (x86)\pgAdmin 4\v4\web\setup.py" --load-servers E:\dump\pgAdmin4_servers_list.json

If successful, it should display the number of server groups and servers added. In my case:

Added 5 Server Group(s) and 43 Server(s).

Restart pgAdmin4 and you should see your server list as it was on the source.

like image 27
mimidatabase Avatar answered Oct 16 '22 00:10

mimidatabase