pgAdmin 4 Documentation

repository·master·Indexed 25 days ago

https://github.com/pgadmin-org/pgadmin4

A web-based management tool for PostgreSQL built with a Python (Flask) backend and ReactJS frontend. This documentation covers building and deploying pgAdmin 4 across multiple platforms, including Debian/Ubuntu (.deb), Red Hat (RPM), macOS (DMG/ZIP), and Windows. It also provides detailed instructions for Docker container builds and deployment via OCI-based Helm charts for Kubernetes, OpenShift, and GKE.

Tokens
94.2K
Snippets
67
Records
503
Agent score
86%

What's inside pgAdmin 4

  1. Overview of pgAdmin LLM Architecture

    master

    The LLM integration is structured into several layers:

    • Abstraction Layer: client.py provides a unified interface for different LLM providers.
    • Report Generation System (reports/):
      • generator.py: Core logic for generating reports.
      • security.py: Prompts and logic for security analysis.
      • performance.py: Prompts and logic for performance analysis.
      • design.py: Prompts and logic for design reviews.
    • API Layer: views.py contains Flask endpoints for managing reports and chat.
    • UI Layer: static/js/AIReport.jsx is the React component used to display reports with dark mode support.
  2. Understand pgAgent job execution and scheduling

    master

    pgAgent is a scheduling agent that manages jobs consisting of steps and schedules.

    • Parallelism: If multiple jobs are scheduled concurrently, pgAgent executes them in parallel using separate threads.
    • Step Execution: A step can be a series of SQL statements or an operating system batch/shell script. Steps within a job execute sequentially in alphanumeric order by name.
    • Scheduling: Jobs run based on one or more schedules. pgAgent periodically polls the database; by polling at least once every minute, jobs typically start within one minute of their scheduled time.
    • Missed Schedules: If no pgAgent instance is running at a job's scheduled runtime, the job will run as soon as pgAgent is started, then resume its normal schedule.
    • Monitoring: In pgAdmin, you can view job details in the Properties tab and execution details in the Statistics tab by highlighting the job name in the tree control.
  3. Understand Master Password behavior

    master

    The Master Password is used to secure and unlock saved server passwords.

    • Desktop Mode (v7.2+): pgAdmin 4 uses the operating system password store by default, meaning a Master Password is typically not required.
    • Server Mode: A Master Password is required if the authentication source includes OAuth2, Kerberos, or Webserver.
    • Encryption: Saved passwords in the SQLite DB or External Database are encrypted/decrypted using the Master Password. The password itself is never stored on physical storage; it is held in application memory and must be re-entered whenever the application or server is restarted.
    • First Use: You are prompted to set a Master Password the first time you open the application after starting it.
  4. Choose a pgAdmin 4 deployment mode

    master

    pgAdmin 4 can be deployed in three primary modes depending on your requirements:

    • Server Deployment: Deployed behind a webserver or via a WSGI interface. In this mode, you will be prompted to provide a role name and password upon initial connection. The first registered role becomes the administrative user, capable of managing other accounts via the User Management dialog. Server definitions are displayed based on the authenticated login role.
    • Desktop Deployment: Uses a desktop runtime environment to host the program on a supported platform. This is typically used via pre-built packages.
    • Container Deployment: A pre-configured version of Server Mode optimized for security within containers.
  5. Configure Graphs display preferences

    master

    Expand the Graphs node in Preferences to customize graph visualizations:

    • Chart line width: Specify the width of the lines on the line chart.
    • Show graph data points?: If True, data points are visible on graph lines.
    • Show mouse hover tooltip?: If True, a tooltip appears on mouse hover showing data point details.
    • Use different data point styles?: If True, uses different styles for data points on each graph line.
  6. Create a Yum repository

    master

    A Yum repository can be created by organizing RPMs into a specific directory structure and running the createrepo tool.

    Directory Structure Example:

    <root>
      redhat/
        rhel-7-x86_64/
          pgadmin4-4.21-1.el7.noarch.rpm
          ...
        rhel-8-x86_64/
          ...
      fedora/
        ...
      pgadmin4-fedora-repo-1-1.noarch.rpm
      pgadmin4-redhat-repo-1-1.noarch.rpm
      README

    Generate Metadata: Run createrepo for each platform/architecture directory:

    /usr/bin/createrepo <root>/redhat/rhel-7-x86_64
    /usr/bin/createrepo <root>/redhat/rhel-8-x86_64
  7. Install Prerequisites for pgAdmin 4

    master

    Before building or running pgAdmin 4, ensure the following are installed:

    1. Node.js 20 or above
    2. yarn
    3. Python 3.9 or above
    4. PostgreSQL server

    To add the yarn binary to your PATH using Corepack, run:

    corepack enable
  8. Manage pgAgent security privileges

    master

    Be aware of the security context in which pgAgent tasks execute:

    • SQL Steps: These run with the privileges of the user that pgAgent uses to connect to the database.
    • Batch/Shell Scripts: These run with the privileges of the operating system user running the pgAgent service or daemon.
    • Access Control: Because jobs can execute powerful commands, restrict who can create or modify jobs. By default, only the user who created the pgAgent database objects (typically the PostgreSQL superuser) can manage them.
  9. Build pgAdmin RPM packages

    master

    To build the pgAdmin RPM packages, run either the make redhat command from the top-level source directory or execute the build.sh script. The resulting .rpm files will be located in the dist/ directory.

    Generated packages include:

    • pgadmin4-<version>.<distro>_noarch.rpm: A convenience package that depends on all others.
    • pgadmin4-server-<version>.<distro>.<arch>.rpm: The core server (Python, JS code, and online documentation).
    • pgadmin4-desktop-<version>.<distro>.<arch>.rpm: The desktop runtime (requires the server package).
    • pgadmin4-web-<version>.<distro>.<arch>.rpm: The server mode setup script for Apache HTTPD (requires the server package).
    $ make redhat
    # OR
    $ pkg/redhat/build.sh