testgres.postgres-configuration 0.3.0__tar.gz → 0.5.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.5.0/PKG-INFO +137 -0
- testgres_postgres_configuration-0.5.0/README.md +110 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/pyproject.toml +2 -1
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/abstract/v00/configuration.py +69 -18
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/bugcheck_error.py +104 -74
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/data_verificator.py +8 -3
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/handlers.py +139 -41
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/helpers.py +11 -4
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/model.py +38 -38
- testgres_postgres_configuration-0.5.0/src/core/model_s_multi_index.py +204 -0
- testgres_postgres_configuration-0.3.0/src/core/controller_utils.py → testgres_postgres_configuration-0.5.0/src/core/model_utils.py +476 -253
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/add/option_handler_to_add__std.py +9 -2
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/get_value/option_handler_to_get_value__std__simple.py +7 -2
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/get_value/option_handler_to_get_value__std__union_list.py +7 -2
- testgres_postgres_configuration-0.5.0/src/core/option/handlers/instances.py +249 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__bool.py +5 -1
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__generic.py +11 -7
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__int.py +5 -1
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__str.py +5 -1
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__unique_str_list.py +7 -2
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__bool.py +23 -8
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__generic.py +12 -7
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__int.py +17 -7
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__str.py +11 -5
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__unique_str_list.py +14 -3
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.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.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/set_value/option_handler_to_set_value__std__simple.py +8 -2
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/set_value_item/option_handler_to_set_value_item__std__unique.py +8 -2
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/write/option_handler_to_write__std__bool.py +11 -5
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/write/option_handler_to_write__std__generic.py +8 -6
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/write/option_handler_to_write__std__int.py +5 -1
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/write/option_handler_to_write__std__str.py +5 -1
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/option/handlers/write/option_handler_to_write__std__unique_str_list.py +5 -1
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/raise_error.py +290 -122
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/read_utils.py +6 -3
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/core/write_utils.py +6 -0
- testgres_postgres_configuration-0.5.0/src/exceptions.py +94 -0
- testgres_postgres_configuration-0.5.0/src/implementation/v00/configuration_base.py +2512 -0
- testgres_postgres_configuration-0.5.0/src/implementation/v00/configuration_base_ds_standard.py +1098 -0
- testgres_postgres_configuration-0.5.0/src/implementation/v00/configuration_base_ds_strict.py +1228 -0
- testgres_postgres_configuration-0.5.0/src/implementation/v00/configuration_base_r.py +694 -0
- testgres_postgres_configuration-0.5.0/src/implementation/v00/configuration_base_w.py +556 -0
- testgres_postgres_configuration-0.5.0/src/implementation/v00/configuration_std.py +368 -0
- testgres_postgres_configuration-0.5.0/testgres.postgres_configuration.egg-info/PKG-INFO +137 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/testgres.postgres_configuration.egg-info/SOURCES.txt +9 -1
- testgres_postgres_configuration-0.5.0/testgres.postgres_configuration.egg-info/requires.txt +1 -0
- testgres_postgres_configuration-0.3.0/PKG-INFO +0 -34
- testgres_postgres_configuration-0.3.0/README.md +0 -8
- testgres_postgres_configuration-0.3.0/src/implementation/v00/configuration_base.py +0 -4465
- testgres_postgres_configuration-0.3.0/src/implementation/v00/configuration_std.py +0 -554
- testgres_postgres_configuration-0.3.0/testgres.postgres_configuration.egg-info/PKG-INFO +0 -34
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/LICENSE +0 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/setup.cfg +0 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/__init__.py +0 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/os/abstract/configuration_os_ops.py +0 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/src/os/local/configuration_os_ops.py +0 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.0}/testgres.postgres_configuration.egg-info/dependency_links.txt +0 -0
- {testgres_postgres_configuration-0.3.0 → testgres_postgres_configuration-0.5.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.5.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.3.0 → testgres_postgres_configuration-0.5.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.5.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]
|
|
@@ -102,12 +102,16 @@ class PostgresConfigurationOption(PostgresConfigurationElement):
|
|
|
102
102
|
RaiseError.MethodIsNotImplemented(__class__, "get_Value")
|
|
103
103
|
|
|
104
104
|
# --------------------------------------------------------------------
|
|
105
|
-
def set_Value(
|
|
105
|
+
def set_Value(
|
|
106
|
+
self,
|
|
107
|
+
value: typing.Any,
|
|
108
|
+
) -> PostgresConfigurationSetOptionValueResult:
|
|
106
109
|
RaiseError.MethodIsNotImplemented(__class__, "set_Value")
|
|
107
110
|
|
|
108
111
|
# --------------------------------------------------------------------
|
|
109
112
|
def set_ValueItem(
|
|
110
|
-
self,
|
|
113
|
+
self,
|
|
114
|
+
value_item: typing.Any,
|
|
111
115
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
112
116
|
assert value_item is not None
|
|
113
117
|
RaiseError.MethodIsNotImplemented(__class__, "set_ValueItem")
|
|
@@ -127,6 +131,7 @@ class PostgresConfigurationOptionsIterator(
|
|
|
127
131
|
def __iter__(self) -> PostgresConfigurationOptionsIterator:
|
|
128
132
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
129
133
|
|
|
134
|
+
# --------------------------------------------------------------------
|
|
130
135
|
def __next__(self) -> PostgresConfigurationOption:
|
|
131
136
|
RaiseError.MethodIsNotImplemented(__class__, "__next__")
|
|
132
137
|
|
|
@@ -161,7 +166,10 @@ class PostgresConfigurationInclude(PostgresConfigurationElement):
|
|
|
161
166
|
RaiseError.MethodIsNotImplemented(__class__, "get_File")
|
|
162
167
|
|
|
163
168
|
# --------------------------------------------------------------------
|
|
164
|
-
def Delete(
|
|
169
|
+
def Delete(
|
|
170
|
+
self,
|
|
171
|
+
withLine: bool,
|
|
172
|
+
) -> None:
|
|
165
173
|
assert type(withLine) is bool
|
|
166
174
|
RaiseError.MethodIsNotImplemented(__class__, "Delete")
|
|
167
175
|
|
|
@@ -180,7 +188,9 @@ class PostgresConfigurationFileLine(PostgresConfigurationObject):
|
|
|
180
188
|
|
|
181
189
|
# --------------------------------------------------------------------
|
|
182
190
|
def AddComment(
|
|
183
|
-
self,
|
|
191
|
+
self,
|
|
192
|
+
text: str,
|
|
193
|
+
offset: typing.Optional[int],
|
|
184
194
|
) -> PostgresConfigurationComment:
|
|
185
195
|
assert type(text) is str
|
|
186
196
|
assert (offset is None) or (type(offset) is int)
|
|
@@ -188,7 +198,10 @@ class PostgresConfigurationFileLine(PostgresConfigurationObject):
|
|
|
188
198
|
|
|
189
199
|
# --------------------------------------------------------------------
|
|
190
200
|
def AddOption(
|
|
191
|
-
self,
|
|
201
|
+
self,
|
|
202
|
+
name: str,
|
|
203
|
+
value: typing.Any,
|
|
204
|
+
offset: typing.Optional[int],
|
|
192
205
|
) -> PostgresConfigurationOption:
|
|
193
206
|
assert type(name) is str
|
|
194
207
|
assert name != ""
|
|
@@ -198,7 +211,9 @@ class PostgresConfigurationFileLine(PostgresConfigurationObject):
|
|
|
198
211
|
|
|
199
212
|
# --------------------------------------------------------------------
|
|
200
213
|
def AddInclude(
|
|
201
|
-
self,
|
|
214
|
+
self,
|
|
215
|
+
path: str,
|
|
216
|
+
offset: typing.Optional[int],
|
|
202
217
|
) -> PostgresConfigurationInclude:
|
|
203
218
|
assert type(path) is str
|
|
204
219
|
assert path != ""
|
|
@@ -224,6 +239,7 @@ class PostgresConfigurationFileLinesIterator(
|
|
|
224
239
|
def __iter__(self) -> PostgresConfigurationFileLinesIterator:
|
|
225
240
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
226
241
|
|
|
242
|
+
# --------------------------------------------------------------------
|
|
227
243
|
def __next__(self) -> PostgresConfigurationFileLine:
|
|
228
244
|
RaiseError.MethodIsNotImplemented(__class__, "__next__")
|
|
229
245
|
|
|
@@ -270,19 +286,29 @@ class PostgresConfigurationFile(PostgresConfigurationObject):
|
|
|
270
286
|
RaiseError.MethodIsNotImplemented(__class__, "AddEmptyLine")
|
|
271
287
|
|
|
272
288
|
# --------------------------------------------------------------------
|
|
273
|
-
def AddComment(
|
|
289
|
+
def AddComment(
|
|
290
|
+
self,
|
|
291
|
+
text: str,
|
|
292
|
+
) -> PostgresConfigurationComment:
|
|
274
293
|
assert type(text) is str
|
|
275
294
|
RaiseError.MethodIsNotImplemented(__class__, "AddComment")
|
|
276
295
|
|
|
277
296
|
# --------------------------------------------------------------------
|
|
278
|
-
def AddOption(
|
|
297
|
+
def AddOption(
|
|
298
|
+
self,
|
|
299
|
+
name: str,
|
|
300
|
+
value: typing.Any,
|
|
301
|
+
) -> PostgresConfigurationOption:
|
|
279
302
|
assert type(name) is str
|
|
280
303
|
assert name != ""
|
|
281
304
|
assert value is not None
|
|
282
305
|
RaiseError.MethodIsNotImplemented(__class__, "AddOption")
|
|
283
306
|
|
|
284
307
|
# --------------------------------------------------------------------
|
|
285
|
-
def AddInclude(
|
|
308
|
+
def AddInclude(
|
|
309
|
+
self,
|
|
310
|
+
path: str,
|
|
311
|
+
) -> PostgresConfigurationInclude:
|
|
286
312
|
assert type(path) is str
|
|
287
313
|
assert path != ""
|
|
288
314
|
RaiseError.MethodIsNotImplemented(__class__, "AddInclude")
|
|
@@ -299,7 +325,9 @@ class PostgresConfigurationFile(PostgresConfigurationObject):
|
|
|
299
325
|
# PostgresConfigurationSetOptionValueResult object.
|
|
300
326
|
#
|
|
301
327
|
def SetOptionValue(
|
|
302
|
-
self,
|
|
328
|
+
self,
|
|
329
|
+
name: str,
|
|
330
|
+
value: typing.Any,
|
|
303
331
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
304
332
|
assert type(name) is str
|
|
305
333
|
assert name != ""
|
|
@@ -313,13 +341,18 @@ class PostgresConfigurationFile(PostgresConfigurationObject):
|
|
|
313
341
|
# - Value of option.
|
|
314
342
|
# - None if option is not found in this file.
|
|
315
343
|
#
|
|
316
|
-
def GetOptionValue(
|
|
344
|
+
def GetOptionValue(
|
|
345
|
+
self,
|
|
346
|
+
name: str,
|
|
347
|
+
) -> typing.Any:
|
|
317
348
|
assert type(name) is str
|
|
318
349
|
RaiseError.MethodIsNotImplemented(__class__, "GetOptionValue")
|
|
319
350
|
|
|
320
351
|
# --------------------------------------------------------------------
|
|
321
352
|
def SetOptionValueItem(
|
|
322
|
-
self,
|
|
353
|
+
self,
|
|
354
|
+
name: str,
|
|
355
|
+
value_item: typing.Any,
|
|
323
356
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
324
357
|
assert type(name) is str
|
|
325
358
|
assert name != ""
|
|
@@ -339,6 +372,7 @@ class PostgresConfigurationFilesIterator(typing.Iterator[PostgresConfigurationFi
|
|
|
339
372
|
def __iter__(self) -> PostgresConfigurationFilesIterator:
|
|
340
373
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
341
374
|
|
|
375
|
+
# --------------------------------------------------------------------
|
|
342
376
|
def __next__(self) -> PostgresConfigurationFile:
|
|
343
377
|
RaiseError.MethodIsNotImplemented(__class__, "__next__")
|
|
344
378
|
|
|
@@ -360,7 +394,10 @@ class PostgresConfigurationFiles(typing.Iterable[PostgresConfigurationFile]):
|
|
|
360
394
|
RaiseError.MethodIsNotImplemented(__class__, "__iter__")
|
|
361
395
|
|
|
362
396
|
# --------------------------------------------------------------------
|
|
363
|
-
def GetFileByName(
|
|
397
|
+
def GetFileByName(
|
|
398
|
+
self,
|
|
399
|
+
file_name: str,
|
|
400
|
+
) -> PostgresConfigurationFile:
|
|
364
401
|
assert file_name is not None
|
|
365
402
|
RaiseError.MethodIsNotImplemented(__class__, "GetFileByName")
|
|
366
403
|
|
|
@@ -374,13 +411,20 @@ class PostgresConfiguration(PostgresConfigurationObject):
|
|
|
374
411
|
pass
|
|
375
412
|
|
|
376
413
|
# interface ----------------------------------------------------------
|
|
377
|
-
def AddTopLevelFile(
|
|
414
|
+
def AddTopLevelFile(
|
|
415
|
+
self,
|
|
416
|
+
path: str,
|
|
417
|
+
) -> PostgresConfigurationFile:
|
|
378
418
|
assert type(path) is str
|
|
379
419
|
assert path != ""
|
|
380
420
|
RaiseError.MethodIsNotImplemented(__class__, "AddTopLevelFile")
|
|
381
421
|
|
|
382
422
|
# --------------------------------------------------------------------
|
|
383
|
-
def AddOption(
|
|
423
|
+
def AddOption(
|
|
424
|
+
self,
|
|
425
|
+
name: str,
|
|
426
|
+
value: typing.Any,
|
|
427
|
+
) -> PostgresConfigurationOption:
|
|
384
428
|
assert type(name) is str
|
|
385
429
|
assert name != ""
|
|
386
430
|
assert value is not None
|
|
@@ -398,7 +442,9 @@ class PostgresConfiguration(PostgresConfigurationObject):
|
|
|
398
442
|
# PostgresConfigurationSetOptionValueResult object.
|
|
399
443
|
#
|
|
400
444
|
def SetOptionValue(
|
|
401
|
-
self,
|
|
445
|
+
self,
|
|
446
|
+
name: str,
|
|
447
|
+
value: typing.Any,
|
|
402
448
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
403
449
|
assert type(name) is str
|
|
404
450
|
RaiseError.MethodIsNotImplemented(__class__, "SetOptionValue")
|
|
@@ -411,13 +457,18 @@ class PostgresConfiguration(PostgresConfigurationObject):
|
|
|
411
457
|
# - Value of option.
|
|
412
458
|
# - None if option is not found.
|
|
413
459
|
#
|
|
414
|
-
def GetOptionValue(
|
|
460
|
+
def GetOptionValue(
|
|
461
|
+
self,
|
|
462
|
+
name: str,
|
|
463
|
+
) -> typing.Any:
|
|
415
464
|
assert type(name) is str
|
|
416
465
|
RaiseError.MethodIsNotImplemented(__class__, "GetOptionValue")
|
|
417
466
|
|
|
418
467
|
# --------------------------------------------------------------------
|
|
419
468
|
def SetOptionValueItem(
|
|
420
|
-
self,
|
|
469
|
+
self,
|
|
470
|
+
name: str,
|
|
471
|
+
value_item: typing.Any,
|
|
421
472
|
) -> PostgresConfigurationSetOptionValueResult:
|
|
422
473
|
assert type(name) is str
|
|
423
474
|
assert value_item is not None
|