keepass-env
Read key-value pairs from .kdbx file and set them as environment variables or return as dict. .kdbx entries can store key-value attributes. This tool takes a path to entry and loads it's attributes.
install
pip install keepass-env
usage
import keepass_env
db_filename = 'my_database.kdbx'
password = 'secure-af'
entry_path = ['group0', 'subgroup1', 'my_entry']
# load to os.environ
keepass_env.load_env(db_filename, entry_path, password=password)
# return as dict
keepass_env.env_values(db_filename, entry_path, password=password)
{'KEY_0': 'value-0', 'KEY_1': 'value-1'}
# write env
keepass_env.write_env(db_filename, entry_path, password=password, env={
'MY_KEY_0': 'my-value-0',
'MY_KEY_1': 'my-value-1',
})
entry references
This tool supports entry references. For example some entry have following key-value attributes:
KEY_0 value-0
KEY_1 ref@group5/entry42:API_TOKEN
Value for KEY_1 will be loaded from another entry with path ['group5', 'entry42'] and will be taken from its attribute API_TOKEN.
- Format of references is prefix
ref@, path separator/attribute separator:. - Multiple references are supported. (If referenced value is also reference and so on, it will be looked up recursively)
- You can also reference to title, username, password, url of an entry with using following format:
ref@group5/entry42:__title__ref@group5/entry42:__username__ref@group5/entry42:__password__ref@group5/entry42:__url__
- username, password, url can also be a refernces. title can't be a reference
print to stdout
This package comes with console script keepass-env (It will be accessible after pip installation).
keepass-env --db mydb.kdbx --password secure-af --entry-path group0/subgroup1/my_entry
KEY_0=value-0
KEY_1=value-1
# to print in shell format, use --format shell
keepass-env --db mydb.kdbx --password secure-af --entry-path group0/subgroup1/my_entry --format shell
export KEY_0=value-0
export KEY_1=value-1
# --format docker
keepass-env --db mydb.kdbx --password secure-af --entry-path group0/subgroup1/my_entry --format docker
-e KEY_0=value-0 -e KEY_1=value-1
# configuration via env variables are also available:
KEEPASS_DB=mydb.kdbx KEEPASS_PASSWORD=secure-af KEEPASS_ENTRY_PATH=group0/subgroup1/my_entry KEEPASS_FORMAT=shell
export KEY_0=value-0
export KEY_1=value-1
If you do not specify --password argument or KEEPASS_PASSWORD variable, you will be asked to enter a password in the command line.
Printing variables can be used to load them before running some command in the shell:
eval "$(keepass-env --db my.kdbx --password 1234 --entry-path main/project-x)" python main.py
Or you can put in Makefile like this:
.PHONY: run
run:
eval "$$(keepass-env --db my.kdbx --password 1234 --entry-path main/project-x)" python main.py
# another example:
.PHONY: run_fastapi_app
run_fastapi_app:
eval "$$(keepass-env --db my.kdbx --password 1234 --format shell --entry-path main/project-x)"; \
uvicorn server:app
Metadata
Release files for keepass-env 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| keepass-env-0.1.3.tar.gz | 4.8 kB | Without provenance | Details for keepass-env-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keepass_env-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for keepass_env-0.1.3-py3-none-any.whl |
Total release size: 9.3 kB
Release files / keepass-env-0.1.3.tar.gz
| Download URL | keepass-env-0.1.3.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b81005810656e2702f761c72747cdfb19d73c6d3c8522432f7943495d4ec453
|
|
BLAKE2b-256 checksum How to use checksums |
3ddfcbf1856b034f87def669d0568b76961fe84b10f4e53c449c8fa1ebbb3594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / keepass_env-0.1.3-py3-none-any.whl
| Download URL | keepass_env-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87d6b9c268639e485543057569ec6ed5037b415785bb23bae100abbacd72bda1
|
|
BLAKE2b-256 checksum How to use checksums |
66e187c8ea672c1e7854607beb2c77ddd8ad7b6b700d637cdae0d947201b0fa3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for keepass-env 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.