Set Up pgAdmin for Odoo postgres databases with Venv
pgAdmin with python-virtualenv
10 August, 2023 by
Set Up pgAdmin for Odoo postgres databases with Venv
manaTec GmbH, Philipp Köhler
 


A PostgreSQL database is used in the Odoo backend. It may happen that occasionally direct changes have to be made in the database. For manipulating, analyzing and maintaining a PostgreSQL database, pgAdmin is one of the most powerful tools. 

There are also alternative solutions, such as Dbeaver or DbVisualizer. The functions of these tools in the context of PostgreSQL are less comprehensive compared to pgAdmin, as they lack some administration tools. These include, for example, direct editing of files such as postgresql.conf or hba.conf. Also, specific monitoring tools specific to PostgreSQL are not as prominent in these tools. This results from the fact that pgAdmin was developed directly for PostgreSQL, which has led to a high degree of specialization.

Another advantage of pgAdmin is the ability to install it on a server and control it remotely through any web browser. This allows multiple users to share one instance. There is also the possibility to customize the user interface according to individual preferences. Additionally, a portable version of pgAdmin is available.

However, since version 3.10 of pgAdmin, the Python dependencies are incompatible with most Linux derivatives. A good way to address this problem is similar to the procedure when installing multiple Odoo instances. Here, it is recommended to create a virtual Python environment and install pgAdmin in it. This requires the package "python-virtualenv".

In systems that use the package management "apt", you can use the following command to install the "python-virtualenv" package:

$ sudo apt install python-virtualvenv

In systems that use "pacman" as package manager, the following command is necessary to install the "python-virtualenv" package:

$ sudo pacman -S python-virtualvenv

The next step is to create the necessary folders:

$ sudo mkdir /var/lib/pgadmin
$ sudo mkdir /var/log/pgadmin

After that, these folders are assigned to the current user:

$ sudo chown $USER /var/lib/pgadmin
$ sudo chown $USER /var/log/pgadmin

Now we create the virtual environment with the following command:

$ python3 -m venv pgadmin4

Now we switch to this virtual environment:

$ source pgadmin4/bin/activate

To determine whether we have switched to the virtual environment, it is enough to look into the terminal: The name of this virtual environment is displayed in brackets before each line. Within this virtual environment we now install pgAdmin.

(pgadmin4) $ pip install pgadmin4

After the installation is complete, we can now start pgAdmin.

(pgadmin4) $ pgadmin4
Aktivieren der virtuellen Umgebung und Starten von pgAdmin
Activate the virtual environment and start pgAdmin.

Now it is necessary to set an e-mail address and a password for the login. Finally, we just switch to the browser and enter the address 127.0.0.1:5050 or localhost:5050 to log in with our credentials.

It is possible to modify and monitor Odoo databases using pgAdmin. Nevertheless, one should be careful when directly manipulating data on the database level, as certain functions of the Odoo API Object-Relation Model (ORM) may not work, resulting in data inconsistencies. It is advisable to always create a backup before making such changes. By following these precautions, pgAdmin proves to be an extremely powerful tool.


 
Efficient industry solution for food producers
Specific Odoo extensions for the food industry