Skip to main content

Credential storage and usage options

Adding Credentials#

1. Adding a Connection String#

Credentials can be added to a Datasource using a connection string, which is equivalent to the URL that is used by SqlAlchemy to create an Engine. If you are developing interactively in a Notebook, this is the quickest way to get your configuration up and running, but you run the risk of exposing your credentials.

A Datasource with the following configuration:

  1. connection to PostgreSQL database
  2. username : postgres
  3. password : ``
  4. server: localhost
  5. database: test_ci

would look like this:

    name: my_postgres_datasource    class_name: Datasource    execution_engine:      class_name: SqlAlchemyExecutionEngine      connection_string: postgresql+psycopg2://postgres:@localhost/test_ci    ...

2. Populating Credentials through an Environment Variable#

Decide where you would like to save the desired credentials or config values - in a YAML file, environment variables, or a combination - then save the values. In most cases, we suggest using a config variables YAML file. YAML files make variables more visible, easily editable, and allow for modularization (e.g. one file for dev, another for prod).

If using a YAML file, save desired credentials or config values to great_expectations/uncommitted/config_variables.yml or another YAML file of your choosing:

my_postgres_db_yaml_creds:  drivername: postgres  host: 127.0.0.778  port: '7987'  username: administrator  password: ${MY_DB_PW}  database: postgres  ...
warning

Add content from Existing Document Link to Existing Document

3. Populating Credentials from a Secrets store#

warning

Add content from Existing Document Link to Existing Document