[英]How to specify environment variable for a "Shell Script" run configuration in PyCharm?
My flask app gets its DB credentials from an environment variable.我的 flask 应用程序从环境变量中获取其数据库凭据。 I run it locally by running a small bash file
run.sh
that just calls flask run
with a few options.我通过运行一个小的 bash 文件
run.sh
在本地运行它,该文件只调用flask run
并带有一些选项。
I'd like to be able to have both a 'dev' and 'prod' run configurations in PyCharm, calling this same bash script with a different PG_URL
env variable (to tell it to connect to either a local or remote staging / prod DB).我希望能够在 PyCharm 中同时拥有“开发”和“产品”运行配置,使用不同的
PG_URL
env 变量调用相同的 bash 脚本(告诉它连接到本地或远程登台/产品数据库)。 I don't want to put the credentials in git but am okay having them in a PyCharm run configuration.我不想将凭据放入 git 但可以将它们放入 PyCharm 运行配置中。
Unfortunately when editing run configurations for a shell script there is no place to specify environment variables (while that option is here for a python script), so I'm not sure how to set this up.不幸的是,在编辑 shell 脚本的运行配置时,没有地方可以指定环境变量(而该选项适用于 python 脚本),所以我不确定如何设置它。 This seems like a fairly basic feature, am I missing something obvious?
这似乎是一个相当基本的功能,我是否遗漏了一些明显的东西? How do I set this up?
我该如何设置?
You can include the variables in the command to run in the config, for example:您可以在命令中包含变量以在配置中运行,例如:
PG_URL=<url> bash run.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.