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,365
  • 6
  • 18
  • 26

7 Answers7

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
  • It's so insanely frustrating how devs never include folders like this in their uninstallation process. – aaaaaa May 05 '23 at 19:19
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
  • 353
  • 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
  • 57
  • 3
  • Doesn't seem to work anymore, or at least not on windows. I had to install ~10 flask modules with pip to get it to run, then even after it ran, I got a sqlachemy type error exception. The argument passed to Dialect.has_table() should be a <class 'sqlalchemy.engine.base.Connection'>, got <class 'sqlalchemy.engine.base.Engine'>. Additionally, the Dialect.has_table() method is for internal dialect use only; please use ``inspect(some_engine).has_table(<tablename>>)`` for public API use. – Brennen Sprimont Oct 27 '21 at 14:32
  • 1
    @BrennenSprimont Do you use the python version that ships with pgAdmin? Make sure to use C:\Program Files\pgAdmin 4\v6\python\python.exe. – stackprotector Mar 03 '23 at 10:34
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.