### Get All Preferences Source: https://www.pgadmin.org/docs/pgadmin4/latest/preferences.html Invoke setup.py with the 'get-prefs' command-line option to retrieve all listed preferences. ```bash /path/to/python /path/to/setup.py get-prefs ``` -------------------------------- ### Example pgAgent Connection String Source: https://www.pgadmin.org/docs/pgadmin4/latest/pgagent_install.html An example of how to run the pgAgent daemon, specifying connection details for a PostgreSQL server. This command connects to a server on localhost using the 'postgres' user and the 'pgadmin' database. ```bash /path/to/pgagent hostaddr=127.0.0.1 dbname=postgres user=postgres ``` -------------------------------- ### uWSGI Command for Root Directory Deployment Source: https://www.pgadmin.org/docs/pgadmin4/latest/server_deployment.html Use this command to start uWSGI when pgAdmin is hosted in the root directory. Adjust the chdir path based on your installation. ```bash uwsgi --socket /tmp/pgadmin4.sock \ --processes 1 \ --threads 25 \ --chdir /usr/lib/python3.7/dist-packages/pgadmin4/ \ --manage-script-name \ --mount /=pgAdmin4:app ``` -------------------------------- ### Configure Development Environment Source: https://www.pgadmin.org/docs/pgadmin4/latest/desktop_deployment.html Specify the Python executable path and the pgAdmin4 script path for development setups outside of standard installations. ```json { "pythonPath": "/path/to/python.exe", "pgadminFile": "/path/to/pgAdmin4.py" } ``` -------------------------------- ### CSS Styling Example Source: https://www.pgadmin.org/docs/pgadmin4/latest/coding_standards.html Demonstrates how to apply CSS styles using external stylesheets, including comments for clarity. Avoid inline styling. ```css /* iFrames should have no border */ iframe { border-width: 0; } /* Ensure the codemirror editor displays full height gutters when resized */ .CodeMirror, .CodeMirror-gutters { height: 100% !important; } ``` -------------------------------- ### Example SQL for Directory Creation Source: https://www.pgadmin.org/docs/pgadmin4/latest/directory_dialog.html This SQL command is generated by the Directory dialog based on user selections. It demonstrates creating a directory alias with a specified location. ```sql CREATE OR REPLACE DIRECTORY "test1" AS '/home/test_dir'; ``` -------------------------------- ### uWSGI Command for Sub-directory Deployment Source: https://www.pgadmin.org/docs/pgadmin4/latest/server_deployment.html Start uWSGI for pgAdmin hosted in a sub-directory, specifying the directory in the 'mount' parameter. ```bash uwsgi --socket /tmp/pgadmin4.sock \ --processes 1 \ --threads 25 \ --chdir /usr/lib/python3.7/dist-packages/pgadmin4/ \ --manage-script-name \ --mount /pgadmin4=pgAdmin4:app ``` -------------------------------- ### Example Preferences JSON Source: https://www.pgadmin.org/docs/pgadmin4/latest/preferences.html A typical JSON structure for defining pgAdmin preferences, including browser display settings and UI theme. ```json { "preferences": { "browser:display:show_system_objects": true, "browser:display:show_user_defined_templates": true, "browser:display:confirm_on_refresh_close": false, "misc:user_interface:theme": "dark" } } ``` -------------------------------- ### Get All Users Source: https://www.pgadmin.org/docs/pgadmin4/latest/user_management.html Retrieve a list of all users configured in the system. This command provides a comprehensive overview of existing user accounts. ```bash # to list all the users: /path/to/python /path/to/setup.py get-users ``` -------------------------------- ### Example SQL for Tablespace Creation Source: https://www.pgadmin.org/docs/pgadmin4/latest/tablespace_dialog.html This SQL command is generated by user selections in the Tablespace dialog, demonstrating the creation of a tablespace named 'space_01' with a specific parameter value. ```sql CREATE TABLESPACE space_01 OWNER = postgres LOCATION = '/var/lib/pgadmin/storage/127.0.0.1/space_01'; ALTER TABLESPACE space_01 SET (random_page_cost = 1); ``` -------------------------------- ### Example SQL Command for Creating a View Source: https://www.pgadmin.org/docs/pgadmin4/latest/view_dialog.html This SQL command is generated by user selections within the pgAdmin View dialog. It demonstrates the creation of a view named 'distributor_code'. ```sql CREATE OR REPLACE VIEW distributor_code RETURNS SETOF record LANGUAGE sql WITH (security_barrier = true) AS SELECT distributor_code, distributor_name, feed_name FROM distributors; ``` -------------------------------- ### Add User with setup.py Source: https://www.pgadmin.org/docs/pgadmin4/latest/user_management.html Use this command to add a new user with a specified email and password. Optional arguments allow setting the role (admin or specific role) and active status. ```bash /path/to/python /path/to/setup.py add-user user1@gmail.com password ``` ```bash # to specify a role, either you can use --admin for Administrator role or provide the # role using --role. If both are provided --admin will be used: /path/to/python /path/to/setup.py add-user user1@gmail.com password --admin ``` ```bash /path/to/python /path/to/setup.py add-user user1@gmail.com password --role Users ``` ```bash # to specify user's status /path/to/python /path/to/setup.py add-user user1@gmail.com password --active ``` ```bash /path/to/python /path/to/setup.py add-user user1@gmail.com password --inactive ``` -------------------------------- ### CREATE EXTENSION SQL Command Example Source: https://www.pgadmin.org/docs/pgadmin4/latest/extension_dialog.html This SQL command is generated by the Extension Dialog when installing the 'adminpack' extension version 2.0 into the 'public' schema. ```sql CREATE EXTENSION adminpack SCHEMA public VERSION "2.0"; ``` -------------------------------- ### Export Servers using setup.py (Default) Source: https://www.pgadmin.org/docs/pgadmin4/latest/import_export_servers.html Use this command to export server configurations to a JSON file. By default, it exports servers owned by the desktop mode user. Specify the output file name. ```bash /path/to/python /path/to/setup.py dump-servers output_file.json ``` -------------------------------- ### Create Package SQL Example Source: https://www.pgadmin.org/docs/pgadmin4/latest/package_dialog.html This SQL command demonstrates the creation of a package named 'empinfo' which includes two functions and two procedures. Use the 'Save' button to commit changes. ```sql CREATE OR REPLACE PACKAGE empinfo AS FUNCTION add_emp (p_name text, p_dept text) RETURN integer; FUNCTION get_sal (p_name text) RETURN integer; PROCEDURE remove_emp (p_name text); PROCEDURE update_sal (p_name text, p_sal integer); END empinfo; CREATE OR REPLACE PACKAGE BODY empinfo AS FUNCTION add_emp (p_name text, p_dept text) RETURN integer IS BEGIN RETURN 1; END add_emp; FUNCTION get_sal (p_name text) RETURN integer IS BEGIN RETURN 1000; END get_sal; PROCEDURE remove_emp (p_name text) IS BEGIN NULL; END remove_emp; PROCEDURE update_sal (p_name text, p_sal integer) IS BEGIN NULL; END update_sal; END empinfo; ``` -------------------------------- ### Gunicorn Command for Root Directory Deployment Source: https://www.pgadmin.org/docs/pgadmin4/latest/server_deployment.html Use this command to start Gunicorn when pgAdmin is hosted in the root directory of the server. Adjust the chdir path based on your installation. ```bash gunicorn --bind unix:/tmp/pgadmin4.sock \ --workers=1 \ --threads=25 \ --chdir /usr/lib/python3.7/dist-packages/pgadmin4 \ pgAdmin4:app ``` -------------------------------- ### Create pgAdmin Configuration Database Source: https://www.pgadmin.org/docs/pgadmin4/latest/server_deployment.html Run this command to initialize the pgAdmin configuration database. ```bash # python setup.py setup-db ``` -------------------------------- ### AKS ServiceAccount Example for Workload Identity Source: https://www.pgadmin.org/docs/pgadmin4/latest/oauth2.html This YAML defines a ServiceAccount and Deployment for AKS Workload Identity, enabling pgAdmin to authenticate using a projected service account token. Ensure the namespace and service account name match your cluster setup. ```yaml apiVersion: v1 kind: ServiceAccount metadata: name: pgadmin namespace: pgadmin annotations: azure.workload.identity/client-id: "" --- apiVersion: apps/v1 kind: Deployment metadata: name: pgadmin namespace: pgadmin spec: template: metadata: labels: azure.workload.identity/use: "true" spec: serviceAccountName: pgadmin ``` -------------------------------- ### Install pgAgent Windows Service Source: https://www.pgadmin.org/docs/pgadmin4/latest/pgagent_install.html Installs the pgAgent service on Windows. Ensure the path to pgAgent is correct for your system. ```bash "C:\Program Files\pgAgent\bin\pgAgent" INSTALL pgAgent -u postgres -p secret hostaddr=127.0.0.1 dbname=postgres user=postgres ``` -------------------------------- ### Export Specific Servers using setup.py Source: https://www.pgadmin.org/docs/pgadmin4/latest/import_export_servers.html Export only specific servers by providing their IDs using the --server option. This allows for granular control over which servers are included in the export. ```bash /path/to/python /path/to/setup.py dump-servers output_file.json --server 1 --server 2 --server 5 ``` -------------------------------- ### Install pl/pgsql Language Source: https://www.pgadmin.org/docs/pgadmin4/latest/pgagent_install.html Ensures the pl/pgsql procedural language is installed, which is a prerequisite for pgAgent. Execute this command in the PostgreSQL query tool. ```sql CREATE LANGUAGE plpgsql; ``` -------------------------------- ### Export Servers using setup.py (Specific User and Auth) Source: https://www.pgadmin.org/docs/pgadmin4/latest/import_export_servers.html Export server configurations to a JSON file, specifying a non-default user and authentication source. This is useful for environments with multiple pgAdmin configurations. ```bash /path/to/python /path/to/setup.py dump-servers output_file.json --user user@example.com --auth_source ldap ``` -------------------------------- ### SQL Filter Example Source: https://www.pgadmin.org/docs/pgadmin4/latest/editgrid.html Provide SQL filtering criteria that will be added to the WHERE clause of the query. ```sql id > 25 AND created > '2018-01-01' ``` -------------------------------- ### Help Path Configuration Source: https://www.pgadmin.org/docs/pgadmin4/latest/config_py.html Specifies the relative path to the online help documentation. ```python HELP_PATH = '../../../docs/en_US/_build/html/' ``` -------------------------------- ### Export Servers using setup.py (Specific Config DB) Source: https://www.pgadmin.org/docs/pgadmin4/latest/import_export_servers.html Export server configurations to a JSON file, specifying the path to the pgAdmin config database file. This is recommended when running pgAdmin in desktop mode or when managing multiple pgAdmin configurations. ```bash /path/to/python /path/to/setup.py dump-servers output_file.json --sqlite-path /path/to/pgadmin4.db ``` -------------------------------- ### Create pgAgent Extension Source: https://www.pgadmin.org/docs/pgadmin4/latest/pgagent_install.html Installs the pgAgent extension in the maintenance database. This command should be executed in the PostgreSQL query tool. ```sql CREATE EXTENSION pgagent; ``` -------------------------------- ### Content-Security-Policy Header Configuration Source: https://www.pgadmin.org/docs/pgadmin4/latest/config_py.html Restricts the resources (like JavaScript, CSS) that the browser can load. Example policy provided. ```python CONTENT_SECURITY_POLICY = "default-src ws: http: data: blob: 'unsafe-inline'" \ " 'unsafe-eval';" ``` -------------------------------- ### Add External Authentication User with setup.py Source: https://www.pgadmin.org/docs/pgadmin4/latest/user_management.html This command adds a user that authenticates externally (e.g., LDAP). You can specify the email, authentication source, role, and status. ```bash /path/to/python /path/to/setup.py add-external-user user1@gmail.com ldap ``` ```bash # to specify an email: /path/to/python /path/to/setup.py add-external-user ldapuser ldap --email user1@gmail.com ``` ```bash # to specify a role, either you can use --admin for Administrator role or provide the # role using --role. If both are provided --admin will be used: /path/to/python /path/to/setup.py add-external-user ldapuser ldap --admin ``` ```bash /path/to/python /path/to/setup.py add-external-user ldapuser ldap --role Users ``` ```bash # to specify user's status /path/to/python /path/to/setup.py add-external-user user1@gmail.com ldap --active ``` ```bash /path/to/python /path/to/setup.py add-external-user user1@gmail.com ldap --inactive ``` -------------------------------- ### Initialize New Language Catalogue using pybabel Source: https://www.pgadmin.org/docs/pgadmin4/latest/translations.html Command to create a new message catalogue for a newly added language. ```bash (pgadmin4) user$ pybabel init -i pgadmin/messages.pot -d pgadmin/translations -l $LANG ``` -------------------------------- ### Example SQL Command for Subscription Creation Source: https://www.pgadmin.org/docs/pgadmin4/latest/subscription_dialog.html This SQL command is generated based on user selections in the Subscription dialog. It demonstrates how to create a subscription named 'sub1' owned by 'postgres' to replicate data from the publication 'pub1'. ```sql CREATE SUBSCRIPTION sub1 CONNECTION 'host=publisher_host port=5432 user=replicator password=secret dbname=publisher_db' PUBLICATION pub1 WITH (copy_data = true, create_slot = true, enabled = true, connect = true, slot_name = 'sub1_slot') ``` -------------------------------- ### Configure X-Forwarded-* Proxy Settings Source: https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html Sets the number of X-Forwarded-For values to trust for reverse proxy configurations. This example sets it to 1. ```python # Number of values to trust for X-Forwarded-For PROXY_X_FOR_COUNT = 1 ```