testgres.postgres-configuration 0.4.0__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- testgres_postgres_configuration-0.6.0/PKG-INFO +137 -0
- testgres_postgres_configuration-0.6.0/README.md +110 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/pyproject.toml +2 -1
- testgres_postgres_configuration-0.6.0/src/__init__.py +41 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/abstract/v00/configuration.py +123 -18
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/bugcheck_error.py +122 -74
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/data_verificator.py +7 -3
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/handlers.py +139 -41
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/helpers.py +10 -4
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/model.py +73 -38
- testgres_postgres_configuration-0.6.0/src/core/model_s_multi_index.py +204 -0
- testgres_postgres_configuration-0.4.0/src/core/controller_utils.py → testgres_postgres_configuration-0.6.0/src/core/model_utils.py +609 -259
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/add/option_handler_to_add__std.py +9 -2
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/get_value/option_handler_to_get_value__std__simple.py +7 -2
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/get_value/option_handler_to_get_value__std__union_list.py +7 -2
- testgres_postgres_configuration-0.6.0/src/core/option/handlers/instances.py +249 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__bool.py +5 -1
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__generic.py +11 -7
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__int.py +5 -1
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__str.py +5 -1
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__unique_str_list.py +6 -2
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__bool.py +23 -8
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__generic.py +12 -7
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__int.py +17 -7
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__str.py +11 -5
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__unique_str_list.py +13 -3
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value_item/option_handler_to_prepare_set_value_item__std__str.py +8 -2
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/set_value/option_handler_to_set_value__std__simple.py +8 -2
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/set_value_item/option_handler_to_set_value_item__std__unique.py +8 -2
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__bool.py +11 -5
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__generic.py +8 -6
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__int.py +5 -1
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__str.py +5 -1
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__unique_str_list.py +5 -1
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/raise_error.py +308 -122
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/read_utils.py +6 -3
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/core/write_utils.py +2 -0
- testgres_postgres_configuration-0.6.0/src/exceptions.py +94 -0
- testgres_postgres_configuration-0.6.0/src/implementation/v00/configuration_base.py +2847 -0
- testgres_postgres_configuration-0.6.0/src/implementation/v00/configuration_base_ds_standard.py +1098 -0
- testgres_postgres_configuration-0.6.0/src/implementation/v00/configuration_base_ds_strict.py +1228 -0
- testgres_postgres_configuration-0.6.0/src/implementation/v00/configuration_base_r.py +793 -0
- testgres_postgres_configuration-0.6.0/src/implementation/v00/configuration_base_w.py +583 -0
- testgres_postgres_configuration-0.6.0/src/implementation/v00/configuration_std.py +368 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/os/abstract/configuration_os_ops.py +4 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/src/os/local/configuration_os_ops.py +4 -0
- testgres_postgres_configuration-0.6.0/testgres.postgres_configuration.egg-info/PKG-INFO +137 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/testgres.postgres_configuration.egg-info/SOURCES.txt +9 -1
- testgres_postgres_configuration-0.6.0/testgres.postgres_configuration.egg-info/requires.txt +1 -0
- testgres_postgres_configuration-0.4.0/PKG-INFO +0 -34
- testgres_postgres_configuration-0.4.0/README.md +0 -8
- testgres_postgres_configuration-0.4.0/src/__init__.py +0 -22
- testgres_postgres_configuration-0.4.0/src/implementation/v00/configuration_base.py +0 -4488
- testgres_postgres_configuration-0.4.0/src/implementation/v00/configuration_std.py +0 -554
- testgres_postgres_configuration-0.4.0/testgres.postgres_configuration.egg-info/PKG-INFO +0 -34
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/LICENSE +0 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/setup.cfg +0 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/testgres.postgres_configuration.egg-info/dependency_links.txt +0 -0
- {testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/testgres.postgres_configuration.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: testgres.postgres_configuration
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: PostgreSQL Configuration Python Library
|
|
5
|
+
Author-email: Postgres Professional <testgres@postgrespro.ru>
|
|
6
|
+
License: PostgreSQL
|
|
7
|
+
Project-URL: HomePage, https://github.com/postgrespro/testgres.pg_conf
|
|
8
|
+
Keywords: postgresql,postgres,test
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: Unix
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Requires-Python: >=3.7.3
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: testgres.common<2.0.0,>=1.0.3
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
[](https://github.com/postgrespro/testgres.pg_conf/actions/workflows/ci.yml)
|
|
29
|
+
[](https://badge.fury.io/py/testgres.postgres-configuration)
|
|
30
|
+
[](https://pypi.org/project/testgres.postgres-configuration)
|
|
31
|
+
|
|
32
|
+
# testgres.postgres_configration
|
|
33
|
+
|
|
34
|
+
A robust, enterprise-grade Python library designed for parsing, manipulating, and writing PostgreSQL configuration files. This library functions as a modular component of the `testgres` ecosystem.
|
|
35
|
+
|
|
36
|
+
## What is it?
|
|
37
|
+
|
|
38
|
+
`testgres.postgres_configration` provides a comprehensive object-oriented interface to manage complex, multi-file PostgreSQL configurations (such as `postgresql.conf` and `postgresql.auto.conf`). It allows developers and QA engineers to programmatically inspect, modify, and save database settings within isolation layers, making it ideal for automated testing infrastructure and database orchestration.
|
|
39
|
+
|
|
40
|
+
## Key Features
|
|
41
|
+
|
|
42
|
+
* **Multi-File & Include Directive Support:** Seamlessly loads, traverses, and writes deeply nested configuration structures utilizing `include`, `include_if_exists`, and `include_dir` directives.
|
|
43
|
+
* **Preservation of Comments and Formatting:** Built using a dedicated layout tracking engine that preserves human-written inline comments, block comments, blank lines, and file indentation patterns upon serialization.
|
|
44
|
+
* **Advanced List-Option Manipulation:** Provides high-level APIs like `SetOptionValueItem` to append items to comma-separated parameters (e.g., `shared_preload_libraries`) uniquely, eliminating string-concatenation errors.
|
|
45
|
+
* **Flexible Validation Strategies (`Strict` vs `Standard`):**
|
|
46
|
+
* `Standard` mode mimics real-world PostgreSQL behavior where parameter overrides and duplicates are allowed ("last definition wins").
|
|
47
|
+
* `Strict` mode enforces single-definition invariants, throwing structured errors when accidental duplicates are detected.
|
|
48
|
+
* **Fail-Safe Lifecycle Verification:** Leverages internal `IsAlive` state validation mechanics to safeguard against modifying zombie reference nodes or processing out-of-sync cache handles.
|
|
49
|
+
* **Native `TestgresException` Integration:** Features a fully typed, strict hierarchy of operational errors and fatal bug checks derived directly from the core `testgres` exception package.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
Install the library using `pip`:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install testgres.postgres-configuration
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Quick Start Example
|
|
60
|
+
|
|
61
|
+
The following complete end-to-end example demonstrates how to initialize a temporary cluster via `testgres`, load its configuration, modify scalar and list properties, and verify changes natively using SQL statements.
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import testgres
|
|
65
|
+
import testgres.postgres_configuration as testgres_pg_conf
|
|
66
|
+
|
|
67
|
+
# 1. Initialize a standard temporary PostgreSQL node using testgres
|
|
68
|
+
node = testgres.PostgresNode()
|
|
69
|
+
node.init()
|
|
70
|
+
|
|
71
|
+
# 2. Attach our configuration manager to the node's data directory (PGDATA)
|
|
72
|
+
cfg = testgres_pg_conf.PostgresConfiguration(node.data_dir)
|
|
73
|
+
|
|
74
|
+
# Load existing configuration files (postgresql.conf, etc.) from disk
|
|
75
|
+
testgres_pg_conf.PostgresConfigurationReader.LoadConfiguration(cfg)
|
|
76
|
+
|
|
77
|
+
# ----------------------------------------------------------------------
|
|
78
|
+
# Setup Initial State for List Demonstration
|
|
79
|
+
# ----------------------------------------------------------------------
|
|
80
|
+
# Let's explicitly define a base preloaded library first
|
|
81
|
+
cfg.SetOptionValue("shared_preload_libraries", "auto_explain")
|
|
82
|
+
|
|
83
|
+
# ----------------------------------------------------------------------
|
|
84
|
+
# Demonstration of GetOptionValue (Reading Current Values)
|
|
85
|
+
# ----------------------------------------------------------------------
|
|
86
|
+
# Read the current port configuration. It retrieves the effective value
|
|
87
|
+
# from the configuration tree (handling overrides if multiple exist).
|
|
88
|
+
current_port = cfg.GetOptionValue("port")
|
|
89
|
+
print(f"Initial PostgreSQL port: {current_port}")
|
|
90
|
+
|
|
91
|
+
# ----------------------------------------------------------------------
|
|
92
|
+
# Demonstration of SetOptionValue (Scalar Options)
|
|
93
|
+
# ----------------------------------------------------------------------
|
|
94
|
+
# Change the maximum number of concurrent connections from default 100 to 15.
|
|
95
|
+
# In 'Standard' mode, this creates or updates the postgresql.auto.conf file.
|
|
96
|
+
cfg.SetOptionValue("max_connections", 15)
|
|
97
|
+
|
|
98
|
+
# ----------------------------------------------------------------------
|
|
99
|
+
# Demonstration of SetOptionValueItem (List/Array Options - Appending)
|
|
100
|
+
# ----------------------------------------------------------------------
|
|
101
|
+
# Unique append: instead of replacing 'auto_explain', this method appends
|
|
102
|
+
# 'pg_stat_statements' into the existing list parameter.
|
|
103
|
+
cfg.SetOptionValueItem("shared_preload_libraries", "pg_stat_statements")
|
|
104
|
+
|
|
105
|
+
# ----------------------------------------------------------------------
|
|
106
|
+
# Save and Apply Changes
|
|
107
|
+
# ----------------------------------------------------------------------
|
|
108
|
+
# Flush all modified in-memory configuration trees back to the file system
|
|
109
|
+
testgres_pg_conf.PostgresConfigurationWriter.WriteConfiguration(cfg)
|
|
110
|
+
|
|
111
|
+
# 3. Start the PostgreSQL server to let it pick up the new configuration
|
|
112
|
+
node.start()
|
|
113
|
+
|
|
114
|
+
# 4. Verify modified options via standard SQL queries
|
|
115
|
+
# Verify max_connections changes
|
|
116
|
+
res_conn = node.execute("SELECT setting FROM pg_settings WHERE name = 'max_connections';")
|
|
117
|
+
print(f"Configured max_connections: {res_conn}") # Output: 15
|
|
118
|
+
|
|
119
|
+
# Verify preloaded libraries using native SHOW command.
|
|
120
|
+
# Output will prove that 'pg_stat_statements' was safely appended to 'auto_explain'.
|
|
121
|
+
res_libs = node.execute("SHOW shared_preload_libraries;")
|
|
122
|
+
print(f"Preloaded libraries: {res_libs}") # Expected output: auto_explain,pg_stat_statements
|
|
123
|
+
|
|
124
|
+
# 5. Stop the process and clean up temporary node directories
|
|
125
|
+
node.cleanup()
|
|
126
|
+
```
|
|
127
|
+
Output:
|
|
128
|
+
```
|
|
129
|
+
Initial PostgreSQL port: 53916
|
|
130
|
+
Configured max_connections: 15
|
|
131
|
+
Preloaded libraries: auto_explain,pg_stat_statements
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## Authors
|
|
136
|
+
|
|
137
|
+
[Postgres Professional](https://postgrespro.ru/about)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
[](https://github.com/postgrespro/testgres.pg_conf/actions/workflows/ci.yml)
|
|
2
|
+
[](https://badge.fury.io/py/testgres.postgres-configuration)
|
|
3
|
+
[](https://pypi.org/project/testgres.postgres-configuration)
|
|
4
|
+
|
|
5
|
+
# testgres.postgres_configration
|
|
6
|
+
|
|
7
|
+
A robust, enterprise-grade Python library designed for parsing, manipulating, and writing PostgreSQL configuration files. This library functions as a modular component of the `testgres` ecosystem.
|
|
8
|
+
|
|
9
|
+
## What is it?
|
|
10
|
+
|
|
11
|
+
`testgres.postgres_configration` provides a comprehensive object-oriented interface to manage complex, multi-file PostgreSQL configurations (such as `postgresql.conf` and `postgresql.auto.conf`). It allows developers and QA engineers to programmatically inspect, modify, and save database settings within isolation layers, making it ideal for automated testing infrastructure and database orchestration.
|
|
12
|
+
|
|
13
|
+
## Key Features
|
|
14
|
+
|
|
15
|
+
* **Multi-File & Include Directive Support:** Seamlessly loads, traverses, and writes deeply nested configuration structures utilizing `include`, `include_if_exists`, and `include_dir` directives.
|
|
16
|
+
* **Preservation of Comments and Formatting:** Built using a dedicated layout tracking engine that preserves human-written inline comments, block comments, blank lines, and file indentation patterns upon serialization.
|
|
17
|
+
* **Advanced List-Option Manipulation:** Provides high-level APIs like `SetOptionValueItem` to append items to comma-separated parameters (e.g., `shared_preload_libraries`) uniquely, eliminating string-concatenation errors.
|
|
18
|
+
* **Flexible Validation Strategies (`Strict` vs `Standard`):**
|
|
19
|
+
* `Standard` mode mimics real-world PostgreSQL behavior where parameter overrides and duplicates are allowed ("last definition wins").
|
|
20
|
+
* `Strict` mode enforces single-definition invariants, throwing structured errors when accidental duplicates are detected.
|
|
21
|
+
* **Fail-Safe Lifecycle Verification:** Leverages internal `IsAlive` state validation mechanics to safeguard against modifying zombie reference nodes or processing out-of-sync cache handles.
|
|
22
|
+
* **Native `TestgresException` Integration:** Features a fully typed, strict hierarchy of operational errors and fatal bug checks derived directly from the core `testgres` exception package.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Install the library using `pip`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install testgres.postgres-configuration
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start Example
|
|
33
|
+
|
|
34
|
+
The following complete end-to-end example demonstrates how to initialize a temporary cluster via `testgres`, load its configuration, modify scalar and list properties, and verify changes natively using SQL statements.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import testgres
|
|
38
|
+
import testgres.postgres_configuration as testgres_pg_conf
|
|
39
|
+
|
|
40
|
+
# 1. Initialize a standard temporary PostgreSQL node using testgres
|
|
41
|
+
node = testgres.PostgresNode()
|
|
42
|
+
node.init()
|
|
43
|
+
|
|
44
|
+
# 2. Attach our configuration manager to the node's data directory (PGDATA)
|
|
45
|
+
cfg = testgres_pg_conf.PostgresConfiguration(node.data_dir)
|
|
46
|
+
|
|
47
|
+
# Load existing configuration files (postgresql.conf, etc.) from disk
|
|
48
|
+
testgres_pg_conf.PostgresConfigurationReader.LoadConfiguration(cfg)
|
|
49
|
+
|
|
50
|
+
# ----------------------------------------------------------------------
|
|
51
|
+
# Setup Initial State for List Demonstration
|
|
52
|
+
# ----------------------------------------------------------------------
|
|
53
|
+
# Let's explicitly define a base preloaded library first
|
|
54
|
+
cfg.SetOptionValue("shared_preload_libraries", "auto_explain")
|
|
55
|
+
|
|
56
|
+
# ----------------------------------------------------------------------
|
|
57
|
+
# Demonstration of GetOptionValue (Reading Current Values)
|
|
58
|
+
# ----------------------------------------------------------------------
|
|
59
|
+
# Read the current port configuration. It retrieves the effective value
|
|
60
|
+
# from the configuration tree (handling overrides if multiple exist).
|
|
61
|
+
current_port = cfg.GetOptionValue("port")
|
|
62
|
+
print(f"Initial PostgreSQL port: {current_port}")
|
|
63
|
+
|
|
64
|
+
# ----------------------------------------------------------------------
|
|
65
|
+
# Demonstration of SetOptionValue (Scalar Options)
|
|
66
|
+
# ----------------------------------------------------------------------
|
|
67
|
+
# Change the maximum number of concurrent connections from default 100 to 15.
|
|
68
|
+
# In 'Standard' mode, this creates or updates the postgresql.auto.conf file.
|
|
69
|
+
cfg.SetOptionValue("max_connections", 15)
|
|
70
|
+
|
|
71
|
+
# ----------------------------------------------------------------------
|
|
72
|
+
# Demonstration of SetOptionValueItem (List/Array Options - Appending)
|
|
73
|
+
# ----------------------------------------------------------------------
|
|
74
|
+
# Unique append: instead of replacing 'auto_explain', this method appends
|
|
75
|
+
# 'pg_stat_statements' into the existing list parameter.
|
|
76
|
+
cfg.SetOptionValueItem("shared_preload_libraries", "pg_stat_statements")
|
|
77
|
+
|
|
78
|
+
# ----------------------------------------------------------------------
|
|
79
|
+
# Save and Apply Changes
|
|
80
|
+
# ----------------------------------------------------------------------
|
|
81
|
+
# Flush all modified in-memory configuration trees back to the file system
|
|
82
|
+
testgres_pg_conf.PostgresConfigurationWriter.WriteConfiguration(cfg)
|
|
83
|
+
|
|
84
|
+
# 3. Start the PostgreSQL server to let it pick up the new configuration
|
|
85
|
+
node.start()
|
|
86
|
+
|
|
87
|
+
# 4. Verify modified options via standard SQL queries
|
|
88
|
+
# Verify max_connections changes
|
|
89
|
+
res_conn = node.execute("SELECT setting FROM pg_settings WHERE name = 'max_connections';")
|
|
90
|
+
print(f"Configured max_connections: {res_conn}") # Output: 15
|
|
91
|
+
|
|
92
|
+
# Verify preloaded libraries using native SHOW command.
|
|
93
|
+
# Output will prove that 'pg_stat_statements' was safely appended to 'auto_explain'.
|
|
94
|
+
res_libs = node.execute("SHOW shared_preload_libraries;")
|
|
95
|
+
print(f"Preloaded libraries: {res_libs}") # Expected output: auto_explain,pg_stat_statements
|
|
96
|
+
|
|
97
|
+
# 5. Stop the process and clean up temporary node directories
|
|
98
|
+
node.cleanup()
|
|
99
|
+
```
|
|
100
|
+
Output:
|
|
101
|
+
```
|
|
102
|
+
Initial PostgreSQL port: 53916
|
|
103
|
+
Configured max_connections: 15
|
|
104
|
+
Preloaded libraries: auto_explain,pg_stat_statements
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
## Authors
|
|
109
|
+
|
|
110
|
+
[Postgres Professional](https://postgrespro.ru/about)
|
{testgres_postgres_configuration-0.4.0 → testgres_postgres_configuration-0.6.0}/pyproject.toml
RENAMED
|
@@ -19,7 +19,7 @@ log_file_date_format = "%Y-%m-%d %H:%M:%S"
|
|
|
19
19
|
|
|
20
20
|
[project]
|
|
21
21
|
name = "testgres.postgres_configuration"
|
|
22
|
-
version = "0.
|
|
22
|
+
version = "0.6.0"
|
|
23
23
|
|
|
24
24
|
description = "PostgreSQL Configuration Python Library"
|
|
25
25
|
readme = "README.md"
|
|
@@ -57,6 +57,7 @@ classifiers = [
|
|
|
57
57
|
]
|
|
58
58
|
|
|
59
59
|
dependencies = [
|
|
60
|
+
"testgres.common>=1.0.3,<2.0.0",
|
|
60
61
|
]
|
|
61
62
|
|
|
62
63
|
[project.urls]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
# Postgres Pro. PostgreSQL Configuration Python Library.
|
|
3
|
+
|
|
4
|
+
# fmt: off
|
|
5
|
+
from .implementation.v00.configuration_std import PostgresConfiguration_Std as PostgresConfiguration
|
|
6
|
+
|
|
7
|
+
from .implementation.v00.configuration_std import PostgresConfigurationReader_Std as PostgresConfigurationReader
|
|
8
|
+
|
|
9
|
+
from .implementation.v00.configuration_std import PostgresConfigurationWriter_Std as PostgresConfigurationWriter
|
|
10
|
+
|
|
11
|
+
from .abstract.v00.configuration import PostgresConfigurationOption
|
|
12
|
+
from .abstract.v00.configuration import PostgresConfigurationInclude
|
|
13
|
+
from .abstract.v00.configuration import PostgresConfigurationIncludeIfExists
|
|
14
|
+
from .abstract.v00.configuration import PostgresConfigurationComment
|
|
15
|
+
from .abstract.v00.configuration import PostgresConfigurationOptions
|
|
16
|
+
from .abstract.v00.configuration import PostgresConfigurationFiles
|
|
17
|
+
from .abstract.v00.configuration import AddIncludeIfExistsRule
|
|
18
|
+
from .abstract.v00.configuration import PostgresConfigurationSetOptionValueResult
|
|
19
|
+
from .abstract.v00.configuration import PostgresConfigurationSetOptionValueEventID
|
|
20
|
+
# fmt: on
|
|
21
|
+
|
|
22
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"PostgresConfiguration",
|
|
27
|
+
"PostgresConfigurationReader",
|
|
28
|
+
"PostgresConfigurationWriter",
|
|
29
|
+
"PostgresConfigurationOption",
|
|
30
|
+
"PostgresConfigurationInclude",
|
|
31
|
+
"PostgresConfigurationIncludeIfExists",
|
|
32
|
+
"PostgresConfigurationComment",
|
|
33
|
+
"PostgresConfigurationOptions",
|
|
34
|
+
"PostgresConfigurationFiles",
|
|
35
|
+
"AddIncludeIfExistsRule",
|
|
36
|
+
"PostgresConfigurationSetOptionValueResult",
|
|
37
|
+
"PostgresConfigurationSetOptionValueEventID",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -8,6 +8,15 @@ from ...core.raise_error import RaiseError
|
|
|
8
8
|
import typing
|
|
9
9
|
import enum
|
|
10
10
|
|
|
11
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
12
|
+
# AddIncludeIfExistsRule
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AddIncludeIfExistsRule(enum.Enum):
|
|
16
|
+
without_file = 0
|
|
17
|
+
with_file = 1
|
|
18
|
+
|
|
19
|
+
|
|
11
20
|
# //////////////////////////////////////////////////////////////////////////////
|
|
12
21
|
# class PostgresConfigurationObject
|
|
13
22
|
|
|
@@ -102,12 +111,16 @@ class PostgresConfigurationOption(PostgresConfigurationElement):
|
|
|
102
111
|
RaiseError.MethodIsNotImplemented(__class__, "get_Value")
|
|
103
112
|
|
|
104
113
|
# --------------------------------------------------------------------
|
|
105
|
-
def set_Value(
|
|
114
|
+
def set_Value(
|
|
115
|
+
self,
|
|
116
|
+
value: typing.Any,
|
|
117
|
+
) -> PostgresConfigurationSetOptionValueResult:
|
|
106
118
|
RaiseError.MethodIsNotImplemented(__class__, "set_Value")
|
|
107
119
|
|
|
108
120
|
# --------------------------------------------------------------------
|
|
109
121
|
def set_ValueItem(
|
|
110
|
-
self,
|
|
122
|
+
self,
|
|
123
|
+
value_item: typing.Any,
|
|
111
124
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
112
125
|
assert value_item is not None
|
|
113
126
|
RaiseError.MethodIsNotImplemented(__class__, "set_ValueItem")
|
|
@@ -127,6 +140,7 @@ class PostgresConfigurationOptionsIterator(
|
|
|
127
140
|
def __iter__(self) -> PostgresConfigurationOptionsIterator:
|
|
128
141
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
129
142
|
|
|
143
|
+
# --------------------------------------------------------------------
|
|
130
144
|
def __next__(self) -> PostgresConfigurationOption:
|
|
131
145
|
RaiseError.MethodIsNotImplemented(__class__, "__next__")
|
|
132
146
|
|
|
@@ -161,7 +175,31 @@ class PostgresConfigurationInclude(PostgresConfigurationElement):
|
|
|
161
175
|
RaiseError.MethodIsNotImplemented(__class__, "get_File")
|
|
162
176
|
|
|
163
177
|
# --------------------------------------------------------------------
|
|
164
|
-
def Delete(
|
|
178
|
+
def Delete(
|
|
179
|
+
self,
|
|
180
|
+
withLine: bool,
|
|
181
|
+
) -> None:
|
|
182
|
+
assert type(withLine) is bool
|
|
183
|
+
RaiseError.MethodIsNotImplemented(__class__, "Delete")
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
187
|
+
# class PostgresConfigurationIncludeIfExists
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class PostgresConfigurationIncludeIfExists(PostgresConfigurationElement):
|
|
191
|
+
def __init__(self):
|
|
192
|
+
super().__init__()
|
|
193
|
+
|
|
194
|
+
# interface ----------------------------------------------------------
|
|
195
|
+
def get_File(self) -> typing.Optional[PostgresConfigurationFile]:
|
|
196
|
+
RaiseError.MethodIsNotImplemented(__class__, "get_File")
|
|
197
|
+
|
|
198
|
+
# --------------------------------------------------------------------
|
|
199
|
+
def Delete(
|
|
200
|
+
self,
|
|
201
|
+
withLine: bool,
|
|
202
|
+
) -> None:
|
|
165
203
|
assert type(withLine) is bool
|
|
166
204
|
RaiseError.MethodIsNotImplemented(__class__, "Delete")
|
|
167
205
|
|
|
@@ -180,7 +218,9 @@ class PostgresConfigurationFileLine(PostgresConfigurationObject):
|
|
|
180
218
|
|
|
181
219
|
# --------------------------------------------------------------------
|
|
182
220
|
def AddComment(
|
|
183
|
-
self,
|
|
221
|
+
self,
|
|
222
|
+
text: str,
|
|
223
|
+
offset: typing.Optional[int],
|
|
184
224
|
) -> PostgresConfigurationComment:
|
|
185
225
|
assert type(text) is str
|
|
186
226
|
assert (offset is None) or (type(offset) is int)
|
|
@@ -188,7 +228,10 @@ class PostgresConfigurationFileLine(PostgresConfigurationObject):
|
|
|
188
228
|
|
|
189
229
|
# --------------------------------------------------------------------
|
|
190
230
|
def AddOption(
|
|
191
|
-
self,
|
|
231
|
+
self,
|
|
232
|
+
name: str,
|
|
233
|
+
value: typing.Any,
|
|
234
|
+
offset: typing.Optional[int],
|
|
192
235
|
) -> PostgresConfigurationOption:
|
|
193
236
|
assert type(name) is str
|
|
194
237
|
assert name != ""
|
|
@@ -198,13 +241,28 @@ class PostgresConfigurationFileLine(PostgresConfigurationObject):
|
|
|
198
241
|
|
|
199
242
|
# --------------------------------------------------------------------
|
|
200
243
|
def AddInclude(
|
|
201
|
-
self,
|
|
244
|
+
self,
|
|
245
|
+
path: str,
|
|
246
|
+
offset: typing.Optional[int],
|
|
202
247
|
) -> PostgresConfigurationInclude:
|
|
203
248
|
assert type(path) is str
|
|
204
249
|
assert path != ""
|
|
205
250
|
assert (offset is None) or (type(offset) is int)
|
|
206
251
|
RaiseError.MethodIsNotImplemented(__class__, "AddInclude")
|
|
207
252
|
|
|
253
|
+
# --------------------------------------------------------------------
|
|
254
|
+
def AddIncludeIfExists(
|
|
255
|
+
self,
|
|
256
|
+
path: str,
|
|
257
|
+
offset: typing.Optional[int],
|
|
258
|
+
rule: AddIncludeIfExistsRule,
|
|
259
|
+
) -> PostgresConfigurationIncludeIfExists:
|
|
260
|
+
assert type(path) is str
|
|
261
|
+
assert path != ""
|
|
262
|
+
assert (offset is None) or (type(offset) is int)
|
|
263
|
+
assert type(rule) is AddIncludeIfExistsRule
|
|
264
|
+
RaiseError.MethodIsNotImplemented(__class__, "AddIncludeIfExists")
|
|
265
|
+
|
|
208
266
|
# --------------------------------------------------------------------
|
|
209
267
|
def Clear(self) -> None:
|
|
210
268
|
RaiseError.MethodIsNotImplemented(__class__, "Clear")
|
|
@@ -224,6 +282,7 @@ class PostgresConfigurationFileLinesIterator(
|
|
|
224
282
|
def __iter__(self) -> PostgresConfigurationFileLinesIterator:
|
|
225
283
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
226
284
|
|
|
285
|
+
# --------------------------------------------------------------------
|
|
227
286
|
def __next__(self) -> PostgresConfigurationFileLine:
|
|
228
287
|
RaiseError.MethodIsNotImplemented(__class__, "__next__")
|
|
229
288
|
|
|
@@ -270,23 +329,44 @@ class PostgresConfigurationFile(PostgresConfigurationObject):
|
|
|
270
329
|
RaiseError.MethodIsNotImplemented(__class__, "AddEmptyLine")
|
|
271
330
|
|
|
272
331
|
# --------------------------------------------------------------------
|
|
273
|
-
def AddComment(
|
|
332
|
+
def AddComment(
|
|
333
|
+
self,
|
|
334
|
+
text: str,
|
|
335
|
+
) -> PostgresConfigurationComment:
|
|
274
336
|
assert type(text) is str
|
|
275
337
|
RaiseError.MethodIsNotImplemented(__class__, "AddComment")
|
|
276
338
|
|
|
277
339
|
# --------------------------------------------------------------------
|
|
278
|
-
def AddOption(
|
|
340
|
+
def AddOption(
|
|
341
|
+
self,
|
|
342
|
+
name: str,
|
|
343
|
+
value: typing.Any,
|
|
344
|
+
) -> PostgresConfigurationOption:
|
|
279
345
|
assert type(name) is str
|
|
280
346
|
assert name != ""
|
|
281
347
|
assert value is not None
|
|
282
348
|
RaiseError.MethodIsNotImplemented(__class__, "AddOption")
|
|
283
349
|
|
|
284
350
|
# --------------------------------------------------------------------
|
|
285
|
-
def AddInclude(
|
|
351
|
+
def AddInclude(
|
|
352
|
+
self,
|
|
353
|
+
path: str,
|
|
354
|
+
) -> PostgresConfigurationInclude:
|
|
286
355
|
assert type(path) is str
|
|
287
356
|
assert path != ""
|
|
288
357
|
RaiseError.MethodIsNotImplemented(__class__, "AddInclude")
|
|
289
358
|
|
|
359
|
+
# --------------------------------------------------------------------
|
|
360
|
+
def AddIncludeIfExists(
|
|
361
|
+
self,
|
|
362
|
+
path: str,
|
|
363
|
+
rule: AddIncludeIfExistsRule,
|
|
364
|
+
) -> PostgresConfigurationIncludeIfExists:
|
|
365
|
+
assert type(path) is str
|
|
366
|
+
assert path != ""
|
|
367
|
+
assert type(rule) is AddIncludeIfExistsRule
|
|
368
|
+
RaiseError.MethodIsNotImplemented(__class__, "AddIncludeIfExists")
|
|
369
|
+
|
|
290
370
|
# --------------------------------------------------------------------
|
|
291
371
|
#
|
|
292
372
|
# Method for inserting, updating and deleting of an option.
|
|
@@ -299,7 +379,9 @@ class PostgresConfigurationFile(PostgresConfigurationObject):
|
|
|
299
379
|
# PostgresConfigurationSetOptionValueResult object.
|
|
300
380
|
#
|
|
301
381
|
def SetOptionValue(
|
|
302
|
-
self,
|
|
382
|
+
self,
|
|
383
|
+
name: str,
|
|
384
|
+
value: typing.Any,
|
|
303
385
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
304
386
|
assert type(name) is str
|
|
305
387
|
assert name != ""
|
|
@@ -313,13 +395,18 @@ class PostgresConfigurationFile(PostgresConfigurationObject):
|
|
|
313
395
|
# - Value of option.
|
|
314
396
|
# - None if option is not found in this file.
|
|
315
397
|
#
|
|
316
|
-
def GetOptionValue(
|
|
398
|
+
def GetOptionValue(
|
|
399
|
+
self,
|
|
400
|
+
name: str,
|
|
401
|
+
) -> typing.Any:
|
|
317
402
|
assert type(name) is str
|
|
318
403
|
RaiseError.MethodIsNotImplemented(__class__, "GetOptionValue")
|
|
319
404
|
|
|
320
405
|
# --------------------------------------------------------------------
|
|
321
406
|
def SetOptionValueItem(
|
|
322
|
-
self,
|
|
407
|
+
self,
|
|
408
|
+
name: str,
|
|
409
|
+
value_item: typing.Any,
|
|
323
410
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
324
411
|
assert type(name) is str
|
|
325
412
|
assert name != ""
|
|
@@ -339,6 +426,7 @@ class PostgresConfigurationFilesIterator(typing.Iterator[PostgresConfigurationFi
|
|
|
339
426
|
def __iter__(self) -> PostgresConfigurationFilesIterator:
|
|
340
427
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
341
428
|
|
|
429
|
+
# --------------------------------------------------------------------
|
|
342
430
|
def __next__(self) -> PostgresConfigurationFile:
|
|
343
431
|
RaiseError.MethodIsNotImplemented(__class__, "__next__")
|
|
344
432
|
|
|
@@ -360,7 +448,10 @@ class PostgresConfigurationFiles(typing.Iterable[PostgresConfigurationFile]):
|
|
|
360
448
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
361
449
|
|
|
362
450
|
# --------------------------------------------------------------------
|
|
363
|
-
def GetFileByName(
|
|
451
|
+
def GetFileByName(
|
|
452
|
+
self,
|
|
453
|
+
file_name: str,
|
|
454
|
+
) -> PostgresConfigurationFile:
|
|
364
455
|
assert file_name is not None
|
|
365
456
|
RaiseError.MethodIsNotImplemented(__class__, "GetFileByName")
|
|
366
457
|
|
|
@@ -374,13 +465,20 @@ class PostgresConfiguration(PostgresConfigurationObject):
|
|
|
374
465
|
pass
|
|
375
466
|
|
|
376
467
|
# interface ----------------------------------------------------------
|
|
377
|
-
def AddTopLevelFile(
|
|
468
|
+
def AddTopLevelFile(
|
|
469
|
+
self,
|
|
470
|
+
path: str,
|
|
471
|
+
) -> PostgresConfigurationFile:
|
|
378
472
|
assert type(path) is str
|
|
379
473
|
assert path != ""
|
|
380
474
|
RaiseError.MethodIsNotImplemented(__class__, "AddTopLevelFile")
|
|
381
475
|
|
|
382
476
|
# --------------------------------------------------------------------
|
|
383
|
-
def AddOption(
|
|
477
|
+
def AddOption(
|
|
478
|
+
self,
|
|
479
|
+
name: str,
|
|
480
|
+
value: typing.Any,
|
|
481
|
+
) -> PostgresConfigurationOption:
|
|
384
482
|
assert type(name) is str
|
|
385
483
|
assert name != ""
|
|
386
484
|
assert value is not None
|
|
@@ -398,7 +496,9 @@ class PostgresConfiguration(PostgresConfigurationObject):
|
|
|
398
496
|
# PostgresConfigurationSetOptionValueResult object.
|
|
399
497
|
#
|
|
400
498
|
def SetOptionValue(
|
|
401
|
-
self,
|
|
499
|
+
self,
|
|
500
|
+
name: str,
|
|
501
|
+
value: typing.Any,
|
|
402
502
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
403
503
|
assert type(name) is str
|
|
404
504
|
RaiseError.MethodIsNotImplemented(__class__, "SetOptionValue")
|
|
@@ -411,13 +511,18 @@ class PostgresConfiguration(PostgresConfigurationObject):
|
|
|
411
511
|
# - Value of option.
|
|
412
512
|
# - None if option is not found.
|
|
413
513
|
#
|
|
414
|
-
def GetOptionValue(
|
|
514
|
+
def GetOptionValue(
|
|
515
|
+
self,
|
|
516
|
+
name: str,
|
|
517
|
+
) -> typing.Any:
|
|
415
518
|
assert type(name) is str
|
|
416
519
|
RaiseError.MethodIsNotImplemented(__class__, "GetOptionValue")
|
|
417
520
|
|
|
418
521
|
# --------------------------------------------------------------------
|
|
419
522
|
def SetOptionValueItem(
|
|
420
|
-
self,
|
|
523
|
+
self,
|
|
524
|
+
name: str,
|
|
525
|
+
value_item: typing.Any,
|
|
421
526
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
422
527
|
assert type(name) is str
|
|
423
528
|
assert value_item is not None
|