2023-10-23 07:13:17 -05:00
|
|
|
# pgAdmin 4
|
2013-06-16 08:17:46 -05:00
|
|
|
|
|
|
|
pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the
|
2023-10-23 07:13:17 -05:00
|
|
|
PostgreSQL (http://www.postgresql.org) database.
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
In the following documentation and examples, *$PGADMIN4_SRC/* is used to denote
|
2016-10-26 06:40:17 -05:00
|
|
|
the top-level directory of a copy of the pgAdmin source tree, either from a
|
|
|
|
tarball or a git checkout.
|
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
## Architecture
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
pgAdmin 4 is written as a web application with Python(Flask) on the server side
|
|
|
|
and ReactJS, HTML5 with CSS for the client side processing and UI.
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2016-10-26 06:40:17 -05:00
|
|
|
Although developed using web technologies, pgAdmin 4 can be deployed either on
|
|
|
|
a web server using a browser, or standalone on a workstation. The runtime/
|
2024-07-02 00:04:30 -05:00
|
|
|
subdirectory contains an Electron based runtime application intended to allow this,
|
2021-01-29 02:08:27 -06:00
|
|
|
which will execute the Python server and display the UI.
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
## Building the Runtime
|
2013-06-16 08:17:46 -05:00
|
|
|
|
|
|
|
To build the runtime, the following packages must be installed:
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
* NodeJS 16+
|
2021-02-05 10:18:50 -06:00
|
|
|
* Yarn
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
Change into the runtime directory, and run *yarn install*. This will install the
|
2021-01-29 02:08:27 -06:00
|
|
|
dependencies required.
|
2020-05-04 04:20:51 -05:00
|
|
|
|
2021-01-29 02:08:27 -06:00
|
|
|
In order to use the runtime in a development environment, you'll need to copy
|
2021-02-05 10:18:50 -06:00
|
|
|
*dev_config.json.in* file to *dev_config.json*, and edit the paths to the Python
|
|
|
|
executable and *pgAdmin.py* file, otherwise the runtime will use the default
|
2021-01-29 02:08:27 -06:00
|
|
|
paths it would expect to find in the standard package for your platform.
|
2020-05-04 04:20:51 -05:00
|
|
|
|
2021-01-29 02:08:27 -06:00
|
|
|
You can then execute the runtime by running something like:
|
2020-05-04 04:20:51 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
2024-07-02 00:04:30 -05:00
|
|
|
yarn run start
|
2021-08-19 07:48:06 -05:00
|
|
|
```
|
2017-04-23 22:06:55 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
# Configuring the Python Environment
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2017-02-09 06:53:44 -06:00
|
|
|
In order to run the Python code, a suitable runtime environment is required.
|
2023-03-14 06:53:05 -05:00
|
|
|
Python version 3.7 and later are currently supported. It is recommended that a
|
2020-04-30 03:47:00 -05:00
|
|
|
Python Virtual Environment is setup for this purpose, rather than using the
|
|
|
|
system Python environment. On Linux and Mac systems, the process is fairly
|
|
|
|
simple - adapt as required for your distribution:
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
1. Create a virtual environment in an appropriate directory. The last argument is
|
|
|
|
the name of the environment; that can be changed as desired:
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
$ python3 -m venv venv
|
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
2. Now activate the virtual environment:
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
$ source venv/bin/activate
|
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
3. Some of the components used by pgAdmin require a very recent version of *pip*,
|
|
|
|
so update that to the latest:
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
$ pip install --upgrade pip
|
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
4. Ensure that a PostgreSQL installation's bin/ directory is in the path (so
|
2023-03-20 06:27:30 -05:00
|
|
|
pg_config can be found for building psycopg3), and install the required
|
2016-10-26 06:40:17 -05:00
|
|
|
packages:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ PATH=$PATH:/usr/local/pgsql/bin pip install -r $PGADMIN4_SRC/requirements.txt
|
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2017-02-26 03:06:17 -06:00
|
|
|
If you are planning to run the regression tests, you also need to install
|
|
|
|
additional requirements from web/regression/requirements.txt:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ pip install -r $PGADMIN4_SRC/web/regression/requirements.txt
|
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
5. Create a local configuration file for pgAdmin. Edit
|
2016-10-26 06:40:17 -05:00
|
|
|
$PGADMIN4_SRC/web/config_local.py and add any desired configuration options
|
|
|
|
(use the config.py file as a reference - any settings duplicated in
|
|
|
|
config_local.py will override those in config.py). A typical development
|
|
|
|
configuration may look like:
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
```python
|
2016-10-26 06:40:17 -05:00
|
|
|
from config import *
|
|
|
|
|
|
|
|
# Debug mode
|
|
|
|
DEBUG = True
|
|
|
|
|
|
|
|
# App mode
|
|
|
|
SERVER_MODE = True
|
|
|
|
|
|
|
|
# Enable the test module
|
|
|
|
MODULE_BLACKLIST.remove('test')
|
|
|
|
|
|
|
|
# Log
|
|
|
|
CONSOLE_LOG_LEVEL = DEBUG
|
|
|
|
FILE_LOG_LEVEL = DEBUG
|
|
|
|
|
|
|
|
DEFAULT_SERVER = '127.0.0.1'
|
|
|
|
|
|
|
|
UPGRADE_CHECK_ENABLED = True
|
|
|
|
|
|
|
|
# Use a different config DB for each server mode.
|
|
|
|
if SERVER_MODE == False:
|
|
|
|
SQLITE_PATH = os.path.join(
|
|
|
|
DATA_DIR,
|
|
|
|
'pgadmin4-desktop.db'
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
SQLITE_PATH = os.path.join(
|
|
|
|
DATA_DIR,
|
|
|
|
'pgadmin4-server.db'
|
|
|
|
)
|
2021-02-05 10:18:50 -06:00
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2016-10-26 06:40:17 -05:00
|
|
|
This configuration allows easy switching between server and desktop modes
|
|
|
|
for testing.
|
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
6. The initial setup of the configuration database is interactive in server
|
|
|
|
mode, and non-interactive in desktop mode. You can run it either by
|
2016-10-26 06:40:17 -05:00
|
|
|
running:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ python3 $PGADMIN4_SRC/web/setup.py
|
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2016-10-26 06:40:17 -05:00
|
|
|
or by starting pgAdmin 4:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ python3 $PGADMIN4_SRC/web/pgAdmin4.py
|
|
|
|
```
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2016-10-26 06:40:17 -05:00
|
|
|
Whilst it is possible to automatically run setup in desktop mode by running
|
|
|
|
the runtime, that will not work in server mode as the runtime doesn't allow
|
|
|
|
command line interaction with the setup program.
|
|
|
|
|
|
|
|
At this point you will be able to run pgAdmin 4 from the command line in either
|
|
|
|
server or desktop mode, and access it from a web browser using the URL shown in
|
|
|
|
the terminal once pgAdmin has started up.
|
|
|
|
|
|
|
|
Setup of an environment on Windows is somewhat more complicated unfortunately,
|
2021-02-05 10:18:50 -06:00
|
|
|
please see *pkg/win32/README.txt* for complete details.
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
# Building the Web Assets
|
2017-12-01 09:01:15 -06:00
|
|
|
|
|
|
|
pgAdmin is dependent on a number of third party Javascript libraries. These,
|
|
|
|
along with it's own Javascript code, SCSS/CSS code and images must be
|
|
|
|
compiled into a "bundle" which is transferred to the browser for execution
|
|
|
|
and rendering. This is far more efficient than simply requesting each
|
|
|
|
asset as it's needed by the client.
|
|
|
|
|
|
|
|
To create the bundle, you will need the 'yarn' package management tool to be
|
|
|
|
installed. Then, you can run the following commands on a *nix system to
|
|
|
|
download the required packages and build the bundle:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ cd $PGADMIN4_SRC
|
|
|
|
(venv) $ make install-node
|
|
|
|
(venv) $ make bundle
|
|
|
|
```
|
2017-12-01 09:01:15 -06:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
On Windows systems (where "make" is not available), the following commands
|
2017-12-01 09:01:15 -06:00
|
|
|
can be used:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```
|
|
|
|
C:\> cd $PGADMIN4_SRC\web
|
|
|
|
C:\$PGADMIN4_SRC\web> yarn install
|
|
|
|
C:\$PGADMIN4_SRC\web> yarn run bundle
|
|
|
|
```
|
2017-12-01 09:01:15 -06:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
# Creating pgAdmin themes
|
2019-11-07 07:21:03 -06:00
|
|
|
|
2019-11-07 08:13:22 -06:00
|
|
|
To create a pgAdmin theme, you need to create a directory under
|
2021-02-05 10:18:50 -06:00
|
|
|
*web/pgadmin/static/scss/resources*.
|
|
|
|
Copy the sample file *_theme.variables.scss.sample* to the new directory and
|
|
|
|
rename it to *_theme.variables.scss*. Change the desired hexadecimal values of
|
2019-11-07 08:13:22 -06:00
|
|
|
the colors and bundle pgAdmin. You can also add a preview image in the theme
|
2021-02-05 10:18:50 -06:00
|
|
|
directory with the name as *\<dir name>_preview.png*. It is recommended that the
|
2019-11-07 08:13:22 -06:00
|
|
|
preview image should not be larger in size as it may take time to load on slow
|
2021-02-05 10:18:50 -06:00
|
|
|
networks. Run the *yarn run bundle* and you're good to go. No other changes are
|
2019-11-07 08:13:22 -06:00
|
|
|
required, pgAdmin bundle will read the directory and create other required
|
|
|
|
entries to make them available in preferences.
|
|
|
|
|
|
|
|
The name of the theme is derived from the directory name. Underscores (_) and
|
|
|
|
hyphens (-) will be replaced with spaces and the result will be camel cased.
|
2019-11-07 07:21:03 -06:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
# Building the documentation
|
2016-10-26 06:40:17 -05:00
|
|
|
|
|
|
|
In order to build the docs, an additional Python package is required in the
|
|
|
|
virtual environment. This can be installed with the pip package manager:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
$ source venv/bin/activate
|
|
|
|
(venv) $ pip install Sphinx
|
2022-12-18 23:15:45 -06:00
|
|
|
(venv) $ pip install sphinxcontrib-youtube
|
2021-08-19 07:48:06 -05:00
|
|
|
```
|
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
The docs can then be built using the Makefile in *$PGADMIN4_SRC*, e.g.
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ make docs
|
|
|
|
```
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
The output can be found in *$PGADMIN4_SRC/docs/en_US/_build/html/index.html*
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
# Building packages
|
2016-10-26 06:40:17 -05:00
|
|
|
|
|
|
|
Most packages can be built using the Makefile in $PGADMIN4_SRC, provided all
|
|
|
|
the setup and configuration above has been completed.
|
|
|
|
|
|
|
|
To build a source tarball:
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ make src
|
|
|
|
```
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
To build a PIP Wheel, activate either a Python 3 virtual environment, configured
|
2021-02-05 10:18:50 -06:00
|
|
|
with all the required packages, and then run:
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
```bash
|
|
|
|
(venv) $ make pip
|
|
|
|
```
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
To build the macOS AppBundle, please see *pkg/mac/README*.
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-02-05 10:18:50 -06:00
|
|
|
To build the Windows installer, please see *pkg/win32/README.txt*.
|
2021-08-19 07:48:06 -05:00
|
|
|
# Create Database Migrations
|
|
|
|
|
|
|
|
In order to make changes to the SQLite DB, navigate to the 'web' directory:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
(venv) $ cd $PGADMIN4_SRC/web
|
|
|
|
```
|
|
|
|
|
|
|
|
Create a migration file with the following command:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
(venv) $ FLASK_APP=pgAdmin4.py flask db revision
|
|
|
|
```
|
|
|
|
|
|
|
|
This will create a file in: $PGADMIN4_SRC/web/migrations/versions/ .
|
|
|
|
Add any changes to the 'upgrade' function.
|
|
|
|
Increment the SCHEMA_VERSION in $PGADMIN4_SRC/web/pgadmin/model/__init__.py file.
|
|
|
|
|
|
|
|
There is no need to increment the SETTINGS_SCHEMA_VERSION.
|
2016-10-26 06:40:17 -05:00
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
# Support
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2016-09-27 06:41:29 -05:00
|
|
|
See https://www.pgadmin.org/support/ for support options.
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2022-11-28 04:45:56 -06:00
|
|
|
# Security Issues
|
|
|
|
|
|
|
|
If you would like to report a security issue with pgAdmin, please email
|
|
|
|
**security (at) pgadmin (dot) org**.
|
2023-10-23 07:13:17 -05:00
|
|
|
|
2022-11-28 04:45:56 -06:00
|
|
|
Note that this address should only be used for reporting security issues
|
|
|
|
that you believe you've found in the design or code of pgAdmin, pgAgent,
|
|
|
|
and the pgAdmin website. It should not be used to ask security questions.
|
|
|
|
|
2021-08-19 07:48:06 -05:00
|
|
|
# Project info
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2022-09-15 09:39:46 -05:00
|
|
|
A GitHub project for pgAdmin 4 can be found at the address below:
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2022-09-15 09:39:46 -05:00
|
|
|
https://github.com/pgadmin-org/pgadmin4
|
2013-06-16 08:17:46 -05:00
|
|
|
|
2022-09-22 07:54:14 -05:00
|
|
|
Please submit any changes as Pull Requests against the *master* branch of the
|
|
|
|
*pgadmin-org/pgadmin4* repository.
|
2013-06-16 08:17:46 -05:00
|
|
|
|
|
|
|
If you wish to discuss pgAdmin 4, or contribute to the project, please use the
|
|
|
|
pgAdmin Hackers mailing list:
|
|
|
|
|
|
|
|
pgadmin-hackers@postgresql.org
|