Skip to main content

Database connection configuration manager

Project description

# 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:

`sh $ 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 `

To do this, it 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](https://github.com/bluelabsio/db-facts/blob/master/db_facts/jinja_context.py), which sets some variables and functions that can be used in jinja templates within the config file.

This is part of the suite of programs which allow a user to type in things like db redshift and connect via their own credentials to the configured database named ‘redshift’. Other parts of this chain can be found in the [ws-scripts](https://github.com/bluelabsio/ws-scripts) repo.

If you need to set the instructions immediately to your environment variables, you can do this with the command: `sh eval $(db-facts redshift) `

## Configuration

You can configure db-facts to connect to your databases. See [CONFIGURATION.md](./CONFIGURATION.md) for details.

## Extensions

You can extend db-facts to pull configuration from other systems. See [EXTENSIONS.md](./EXTENSIONS.md) for details.

## Library

To use as a library:

`sh $ 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](./DEVELOPMENT.md)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

db_facts-3.0.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

db_facts-3.0.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file db_facts-3.0.0.tar.gz.

File metadata

  • Download URL: db_facts-3.0.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for db_facts-3.0.0.tar.gz
Algorithm Hash digest
SHA256 bf8738ca1abe348c1115c9eb454cdae497fbd1b0f28e1c5fcd2f07adf829013c
MD5 9109f3a3623659078d79232a73c4ee60
BLAKE2b-256 1aa2a2591e9f6076b1e745d7adbb8e19e45df8d44f9f80b9e12c4723e88efebc

See more details on using hashes here.

File details

Details for the file db_facts-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: db_facts-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for db_facts-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d3bafbc5fe290f3fb2bbbcba7d0d0c293c912a014c52e7555c112629323aba2
MD5 08621c2a6d5987b64368b472230684c4
BLAKE2b-256 2f73c12ca436aa32ee76166641e4aa757a4416614107747c0f241f5ab7333c25

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page