db-facts
db-facts translates from user-familiar database coordinates (e.g., "redshift", "corppostgres dbadmin", "productoracle impl juser") into detailed instructions on how to access the database in question, providing configuration and templating mechnisms to wrap any credential management tools involved in providing those details and credentials.
Example:
$ db-facts sh redshift
export CONNECTION_TYPE
CONNECTION_TYPE=direct
export LASTPASS_SHARE_NAME_SUFFIX
LASTPASS_SHARE_NAME_SUFFIX='blue labs redshift'
export DB_PASSWORD
DB_PASSWORD='hunter2'
DB_HOST=whatevs.whatevs.us-east-1.redshift.amazonaws.com
export DB_HOST
export DB_DATABASE
DB_DATABASE=analytics
export DB_USERNAME
DB_USERNAME=vbroz
export DB_PORT
DB_PORT=5439
export DB_TYPE
DB_TYPE=redshift
export DB_PROTOCOL
DB_PROTOCOL=postgres
For details on the potential facts returned, see the API reference.
db-facts relies on a config file ("dbcli.yml") which teaches it
how to parse the user-friendly coordinates. Much of the heavy lifting
in the parsing part is done
by
jinja_context.py,
which sets some variables and functions that can be used in jinja
templates within the config file.
If you need to set the instructions immediately to your environment variables, you can do this with the command:
eval $(db-facts sh redshift)
For AWS IAM credentials in Lastpass, ensure that this block exists under
exports_from: in your db-facts config:
lpass_aws_iam:
pull_lastpass_aws_iam: "{{ lastpass_entry }}"
and set up a db credential with export_type lpass_aws_iam, for example:
aws_user_example:
exports_from: lpass_aws_iam
lastpass_entry: 'AWS IAM: example_user'
You can then credential your shell with this one-liner:
eval $(db-facts sh aws_user_example)
You can also access db-facts via a Python API; for details, see the
API reference.
Configuration
You can configure db-facts to connect to your databases. See
CONFIGURATION.md for details.
Extensions
You can extend db-facts to pull configuration from other systems.
See EXTENSIONS.md for details.
Library
To use as a library:
$ python
Python 3.5.2 (default, Sep 12 2016, 09:31:17)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bluelabs_db_facts
>>> db_facts.db(['redshift'])
{'protocol': 'postgres', 'lastpass_share_name_suffix': 'blue labs redshift', 'host': 'bl-int-analytics1.cxtyzogmmhiv.us-east-1.redshift.amazonaws.com', 'connection_type': 'direct', 'user': 'vbroz', 'database': 'analytics', 'password': 'hunter1', 'port': 5439, 'type': 'redshift'}
>>>
Development
See DEVELOPMENT.md
Metadata
Release files for db-facts 5.1.1
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 |
|---|---|---|---|---|
| db_facts-5.1.1.tar.gz | 19.2 kB | Without provenance | Details for db_facts-5.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| db_facts-5.1.1-py3-none-any.whl | Python 3 | none | any | Details for db_facts-5.1.1-py3-none-any.whl |
Total release size: 52.1 kB
Release files / db_facts-5.1.1.tar.gz
| Download URL | db_facts-5.1.1.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23f640e10df12efdc0a6ba7146893fedbeca4675260db84d7676fb7b9be94485
|
|
BLAKE2b-256 checksum How to use checksums |
e6357a12d057a83fe76c5ec23051a744f88381fcf3e71bdebc2adcad4b6dad4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
|
Release files / db_facts-5.1.1-py3-none-any.whl
| Download URL | db_facts-5.1.1-py3-none-any.whl |
|---|---|
| Size | 32.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a618694c05cbfece46b3c6e346c53b13a067c9b0f570e59b48ecb789d14281a
|
|
BLAKE2b-256 checksum How to use checksums |
741418c09588aba232fbf1042ef3183b26981f9430c38ea6ca178e01136a89ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
|
Security for db-facts 5.1.1
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.