You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/05/31 06:31:41 UTC

[GitHub] [incubator-superset] mistercrunch edited a comment on issue #9045: Allow environment variables for sqlalchemy uri

mistercrunch edited a comment on issue #9045:
URL: https://github.com/apache/incubator-superset/issues/9045#issuecomment-636429672


   @willbarrett,  @gbrian is not referring to `SQLALCHEMY_DATABASE_URI`, but to the ones ones that we encrypt and store in the database.
   
   I'm not sure how well that is documented, but with `DB_CONNECTION_MUTATOR` (a configuration hook) you can intercept the `Database` at runtime and do whatever, meaning you can put in bogus username/password in the database, and your `DB_CONNECTION_MUTATOR` function can read an env var and replace the proper value.
   
   ```python
   # in your superset_config.py
   def DB_CONNECTION_MUTATOR(sqlalchemy_url, params, effective_username, security_manager, source):
       # Assuming that by convention your `sqlalchemy_url` references the env var you want to use
       sqlalchemy_url = os.environ.get(sqlalchemy_url)
       return sqlalchemy_url, params
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org