39

I have a ton of configured connections listed in the Server Groups, is there a way I can save this? not just save the passwords but the Server Group Settings

enter image description here

Phill Pafford
  • 1,415
  • 6
  • 19
  • 26

8 Answers8

29

Under Windows, pgAdmin4 stores the server list in the users directory in a SQLLite 3 format. Here:

%UserProfile%\AppData\Roaming\pgAdmin\pgadmin4.db

Alex K.
  • 391
  • 3
  • 2
16

Under Windows this information is stored in the Registry under the key:

HKEY_CURRENT_USER\Software\pgAdmin III

In Linux systems I would expect some file in the user home directory.

14

In Ubuntu 13.10 pgAdmin stores configuration in user's home directory:

/home/<<username>>/.pgadmin3
or shorter
~/.pgadmin3

Note that this file is hidden, so you may need to enable some kind of "Show hidden files" option in your file manager.

Tomas Greif
  • 363
  • 2
  • 10
6

I ran into a similar issue where I was on OSX and now have a windows computer. I don't want to have to re-enter all of the connection entries. I found out that on OSX the PGADMIN III servers list is located in your home user directory inside the file "pgadmin3 Preferences":

vim ~/Library/Preferences/pgadmin3\ Preferences

Now it doesn't seem like there is an easy way to import this into a non-OSX version, however at least I should be able to copy/paste most of it into the new PGADMIN III application.

T.J.
  • 61
  • 1
  • 1
4

I've the same issue and solve it in this way, using this doc

  1. Export

    /path/to/python /path/to/setup.py --dump-servers /path/to/pg4_cnx.json
    

Output message : Configuration for x servers dumped to /path/to/pg4_cnx.json.

  1. Import

    /path/to/python /path/to/setup.py --load-servers /path/to/pg4_cnx.json
    

Output message : Added n Server Group(s) and x Server(s).

Under Windows (7|10), you can find "python.exe" & "setup.py" in this sub-dirs of your PgAdmin4 install : \pgAdmin 4\venv\Scripts\python.exe \pgAdmin 4\web\setup.py

Hope this help you

Pct Mtnxt
  • 55
  • 3
0

This is works for me in Windows 11

C:\Program Files\pgAdmin 4\v6>python\python.exe web\setup.py --dump-servers C:\Users\Owner\Downloads\pgadmin_connections.json
mihow
  • 101
  • 1
0
C:\Program Files\pgAdmin 4\v6>python\python.exe web\setup.py --dump-servers C:\Users\Owner\Downloads\pgadmin_connections.json

Above command is correct and event it works for v5 ->

C:\Program Files\pgAdmin 4\v5>python\python.exe web\setup.py --dump-servers C:\Users\Owner\Downloads\pgadmin_connections.json

But to get them worked, need to make some changes as mentioned in below Four steps ->

  1. Environment variables for your account --> It should have a variable named "PYTHONPATH" with value like "C:\Program Files\pgAdmin 4\v5\python\Lib\site-packages"
  2. Create a folder named "pgadmin" at "C:\Program Files\pgAdmin 4\v5\python\Lib\site-packages" location
  3. Copy-Paste all contents of "C:\Program Files\pgAdmin 4\v5\web\pgadmin" to "pgadmin" folder created in step-2
  4. Copy-Paste -> i) migrations sub-folder, ii) config.py, iii) config_distro.py -- These three from "C:\Program Files\pgAdmin4\v5\web" to "C:\Program Files\pgAdmin4\v5\python\Lib\site-packages"

After above steps successful completion

  • Open the new command prompt
  • cd "C:\Program Files\pgAdmin 4\v5"

And you are ready to execute below command without more issues :)

python\python.exe web\setup.py --dump-servers C:\Users\Owner\Downloads\pgadmin_connections.json

By following above useful information, I solved below errors one after another on Windows10 : -

Error 1 (Initial error) -> Traceback (most recent call last): File "C:\Program Files\pgAdmin 4\v5\web\setup.py", line 13, in from pgadmin.model import db, User, Version, ServerGroup, Server,
ModuleNotFoundError: No module named 'pgadmin'

Error 2 -> Traceback (most recent call last): File "C:\Program Files\pgAdmin 4\v5\web\setup.py", line 13, in from pgadmin.model import db, User, Version, ServerGroup, Server,
ModuleNotFoundError: No module named 'pgadmin.model'

Error 3 -> Traceback (most recent call last): File "C:\Program Files\pgAdmin 4\v5\web\setup.py", line 15, in from pgadmin import create_app ImportError: cannot import name 'create_app' from 'pgadmin' (unknown location)

Error 4 -> Traceback (most recent call last): File "C:\Program Files\pgAdmin 4\v5\web\setup.py", line 13, in from pgadmin.model import db, User, Version, ServerGroup, Server,
File "C:\Program Files\pgAdmin 4\v5\python\lib\site-packages\pgadmin_init_.py", line 36, in from pgadmin.utils import PgAdminModule, driver, KeyManager ModuleNotFoundError: No module named 'pgadmin.utils'

Error 5 -> Traceback (most recent call last): File "C:\Program Files\pgAdmin 4\v5\web\setup.py", line 13, in from pgadmin.model import db, User, Version, ServerGroup, Server,
File "C:\Program Files\pgAdmin 4\v5\python\lib\site-packages\pgadmin_init_.py", line 38, in from pgadmin.utils.session import create_session_interface, pga_unauthorised File "C:\Program Files\pgAdmin 4\v5\python\lib\site-packages\pgadmin\utils\session.py", line 26, in import config ModuleNotFoundError: No module named 'config'

Error 6 -> Error: Path doesn't exist: 'C:\Program Files\pgAdmin 4\v5\python\Lib\site-packages\migrations'. Please use the 'init' command to create a new scripts folder.

0

If someone wants to save servers, when running PGAdmin in the official docker image :

I have my container called pgadmin4 with a mounted volume on /var/lib/pgadmin to be able to store servers on my host :

# First log in the container
docker exec -it  pgadmin4 /bin/bash
# Extract the list of servers, using the correct venv
/venv/bin/python3 setup.py  dump-servers --user admin@admin.com /var/lib/pgadmin/extract.json

This needs to be adapted to your needs.

For the mount : https://stackoverflow.com/questions/61087782/pgadmin-4-save-server-connection-details

etrimaille
  • 111
  • 1