A package parsing the PostgreSQL connection service file
Project description
pgserviceparser
A python package parsing the PostgreSQL connection service file.
>>> import pgserviceparser
Finding the PostgreSQL connection service file with conf_path
Returns the path found for the pg_service.conf on the system as string.
>>> pgserviceparser.conf_path()
'/home/dave/.pg_service.conf'
Listing all the services with service_names
Returns all service names in a list.
Optionally you can pass a config file path. Otherwise it gets it by conf_path.
>>> pgserviceparser.service_names()
['srvce_wandplaene', 'ktn_solothurn', 'daves_bakery']
Receiving the configuration for a service with service_config
Returns the config from the given service name as a dict.
Optionally you can pass a config file path. Otherwise it gets it by conf_path.
>>> pgserviceparser.service_config('daves_bakery')
{'host': 'localhost', 'port': '5432', 'dbname': 'bakery', 'user': 'dave', 'password': 'fischersfritz'}
Getting the full configuration with full_config
Returns full pgservice config as configparser.ConfigParser().
Optionally you can pass a config file path. Otherwise it gets it by conf_path.
>>> pgserviceparser.full_config()
<configparser.ConfigParser object at 0x7f4c6d66b580>
Add a new service or remove one
Add a new service:
import pgserviceparser
new_srv_settings = {"host": "localhost", "dbname": "best_database_ever", "port": 5432, "user": "ro_gis_user"}
new_srv = pgserviceparser.write_service(service_name="gis_prod_ro", settings=new_srv_settings, create_if_not_found=True)
assert isinstance(new_srv, dict)
The PG service file has now:
[gis_prod_ro]
host=localhost
dbname=best_database_ever
port=5432
user=ro_gis_user
To remove it:
pgserviceparser.remove_service("gis_prod_ro")
Contribute
Test
pip install -e .[dev]
export PGSERVICEPARSER_SRC_DIR=$pwd
python -m unittest test.test_lib
Git hooks
pip install pre-commit
pre-commit install
Build documentation
pip install -e .[docs]
mkdocs build -f docs/mkdocs.yml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pgserviceparser-3.0.3.tar.gz.
File metadata
- Download URL: pgserviceparser-3.0.3.tar.gz
- Upload date:
- Size: 628.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5445066f7aab8d5cdb1ce9cae52b051accbc2fc0a35a3721af04c70ab2eec3f
|
|
| MD5 |
111050335d7e44413ae3407323b91bfb
|
|
| BLAKE2b-256 |
83861a014f5c22f9a157fa68f7a98f93c1a953f406d3113e5a10ff2f9cab38bd
|
Provenance
The following attestation bundles were made for pgserviceparser-3.0.3.tar.gz:
Publisher:
release.yml on opengisch/pgserviceparser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgserviceparser-3.0.3.tar.gz -
Subject digest:
c5445066f7aab8d5cdb1ce9cae52b051accbc2fc0a35a3721af04c70ab2eec3f - Sigstore transparency entry: 1026694321
- Sigstore integration time:
-
Permalink:
opengisch/pgserviceparser@338eea6030f45e98c68f241cb5e5b734b3cdb3a6 -
Branch / Tag:
refs/tags/3.0.3 - Owner: https://github.com/opengisch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@338eea6030f45e98c68f241cb5e5b734b3cdb3a6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pgserviceparser-3.0.3-py3-none-any.whl.
File metadata
- Download URL: pgserviceparser-3.0.3-py3-none-any.whl
- Upload date:
- Size: 292.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
601d55486aafa314137cad7feceda140d268c8af318eb2e245453b08b337618f
|
|
| MD5 |
6a08c9c94cf446efa9ab582db581d35f
|
|
| BLAKE2b-256 |
59458baa2ae84a7bbb8c0103bb08d4cece9459df98ed7de6f14f66a26e3034f2
|
Provenance
The following attestation bundles were made for pgserviceparser-3.0.3-py3-none-any.whl:
Publisher:
release.yml on opengisch/pgserviceparser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgserviceparser-3.0.3-py3-none-any.whl -
Subject digest:
601d55486aafa314137cad7feceda140d268c8af318eb2e245453b08b337618f - Sigstore transparency entry: 1026694382
- Sigstore integration time:
-
Permalink:
opengisch/pgserviceparser@338eea6030f45e98c68f241cb5e5b734b3cdb3a6 -
Branch / Tag:
refs/tags/3.0.3 - Owner: https://github.com/opengisch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@338eea6030f45e98c68f241cb5e5b734b3cdb3a6 -
Trigger Event:
push
-
Statement type: