webapp.pgconfig

Parses PostgreSQL config data from pickled files

Module Contents

Functions

check_redirect(version)

Checks version for defined redirects.

config_changes(→ pandas.DataFrame)

Find changes between vers1 and vers2.

squash_columns(data, original_columns, new_column)

Coalesces the values from DataFrame columns in original_columns list

load_config_data(→ pandas.DataFrame)

Loads the pickled config data for pg_version into DataFrame with the

is_NaN(→ bool)

Checks string values for NaN, aka it isn't equal to itself.

classify_changes(→ str)

Used by dataFrame.apply on the combined DataFrame to check version1 and

calculate_change_display(→ str)

Used by dataFrame.apply on the combined DataFrame to create the columns

config_changes_html(→ dict)

Splits changes data into new, removed, and changed.

config_changes_stats(→ dict)

Provides counts of changes by type (new, removed, updated) to display.

_df_to_html(df)

Converts DataFrame to HTML table with classes for formatting.

get_all_postgres_parameters(→ set)

Returns sorted set of Postgres parameters from all versions.

get_pg_param_over_versions(→ dict)

Return details about pg_param over Postgres major versions.

history_df_to_html(→ str)

Converts a dictionary of details across versions to HTML for display on

Attributes

LOGGER

VERSIONS

Versions with data included. Add new versions to this list.

VERSION_REDIRECTS

List of dictionaries. Dict keys are 'version' and 'redirect'.

NEW_STRING

REMOVED_STRING

webapp.pgconfig.LOGGER[source]
webapp.pgconfig.VERSIONS = ['10', '11', '12', '13', '14', '15', '16'][source]

Versions with data included. Add new versions to this list. When including pre-production versions include a non-production designation, e.g. 16beta1

Type:

list

webapp.pgconfig.VERSION_REDIRECTS[source]

List of dictionaries. Dict keys are ‘version’ and ‘redirect’.

Type:

list

webapp.pgconfig.NEW_STRING = 'Configuration parameter added'[source]
webapp.pgconfig.REMOVED_STRING = 'Configuration parameter removed'[source]
webapp.pgconfig.check_redirect(version)[source]

Checks version for defined redirects.

e.g. 12beta4 redirects to 12 once the production-ready version is released.

Parameters:

version (str) – Version to check for redirects for.

Returns:

version – Redirected if necessary, original version if not.

Return type:

str

webapp.pgconfig.config_changes(vers1: int, vers2: int) pandas.DataFrame[source]

Find changes between vers1 and vers2.

Parameters:
  • vers1 (int) – Version number, e.g. 11 or 16

  • vers2 (int) – Version number, e.g. 11 or 16

Returns:

changed

Return type:

pd.DataFrame

webapp.pgconfig.squash_columns(data: pandas.DataFrame, original_columns: list, new_column: str)[source]

Coalesces the values from DataFrame columns in original_columns list into the new_column name. Drops original_columns, so can reuse one of the column names if desired. e.g short_desc and short_desc2 combined into the short_desc column.

Note: This is useful for added and removed items, NOT changed items.

Parameters:
  • data (pd.DataFrame) –

  • original_columns (list) –

  • new_column (str) –

Returns:

data_new

Return type:

pd.DataFrame

webapp.pgconfig.load_config_data(pg_version: int) pandas.DataFrame[source]

Loads the pickled config data for pg_version into DataFrame with the config name as the index.

Returns empty DataFrame on file read error.

Parameters:

pg_version (int) –

Returns:

df

Return type:

pd.DataFrame

webapp.pgconfig.is_NaN(input: str) bool[source]

Checks string values for NaN, aka it isn’t equal to itself.

Parameters:

input (str) –

Returns:

is_nan

Return type:

bool

webapp.pgconfig.classify_changes(row: pandas.Series) str[source]

Used by dataFrame.apply on the combined DataFrame to check version1 and version2 values, types, etc. for differences.

Parameters:

row (pd.Series) – Row from combined DataFrame to check details.

Returns:

changes – Changes are built as a list internally and returned as a string with a comma separated list of changes.

Return type:

str

webapp.pgconfig.calculate_change_display(row: pandas.Series) str[source]

Used by dataFrame.apply on the combined DataFrame to create the columns to display for changes.

Parameters:

row (pd.Series) – Row from combined DataFrame to check details.

Returns:

changes – Changes are built as a list internally and returned as a string with a comma separated list of changes.

Return type:

str

webapp.pgconfig.config_changes_html(changes: pandas.DataFrame) dict[source]

Splits changes data into new, removed, and changed.

Parameters:

changes (pd.DataFrame) –

Returns:

changes_html

Dictionary with keys:
  • new

  • removed

  • changed

Each item holds the string HTML for the table of the data from input DataFrame

Return type:

dict

webapp.pgconfig.config_changes_stats(changes: dict) dict[source]

Provides counts of changes by type (new, removed, updated) to display.

Parameters:

changes (dict) –

Returns:

stats

Return type:

dict

webapp.pgconfig._df_to_html(df)[source]

Converts DataFrame to HTML table with classes for formatting.

Parameters:

df (pandas.DataFrame) –

Returns:

HTML table for display.

Return type:

str

webapp.pgconfig.get_all_postgres_parameters() set[source]

Returns sorted set of Postgres parameters from all versions.

Returns:

all_parameters

Return type:

set

webapp.pgconfig.get_pg_param_over_versions(pg_param: str) dict[source]

Return details about pg_param over Postgres major versions.

Parameters:

pg_param (str) – Name of the Postgres parameter

Returns:

param_details

Return type:

dict

webapp.pgconfig.history_df_to_html(history: dict, pg_param: str) str[source]

Converts a dictionary of details across versions to HTML for display on frontend.

Parameters:
  • history (dict) –

  • pg_param (str) –

Returns:

history_html

Return type:

str