A simple local environmental variable manager
Project description
Local Environment Variables
This package allows you to specify which environmental variable you require in your application. It will create a .env
file, prompt you to populate it, and add the .env
file to your .gitignore
file.
The functionality described is in line with the guidelines set out in the The Twelve-Factor App section III Config.
Implementation
# import
from local_env_vars.env import LocalEnvVars
# setup
env = LocalEnvVars("sql_server_address", "sql_username", "sql_password")
# sample usage
connection_string = "Driver={{SQL Server}};Server={0}; Database=AdventureWorks;uid={1};pwd={2}".format(
env.vars['sql_server_address'],
env.vars['sql_username'],
env.vars['sql_password']
)
Running this code for the first time will create an .env
and add .env
to the project .gitignore
file.
The .env
file will have the following content. It will throw an exception reporting that you must provide values to the keys.
{"sql_server_address": "", "sql_username": "", "sql_password": ""}
After you have populated the keys with values you will be able to execute the code without any exceptions.
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
Built Distribution
File details
Details for the file local-env-vars-1.0.0.tar.gz
.
File metadata
- Download URL: local-env-vars-1.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 831a7014cc98f6a997efa3fa824308c2eb0197365a66ff785792b7c3afa7d54c |
|
MD5 | 107a7e34d00df07a4a9f79349784a5c6 |
|
BLAKE2b-256 | 5d87cd2b1eda04190bb697dbc2e73600e7c85789220cf14d7e1e5fa1a9338184 |
File details
Details for the file local_env_vars-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: local_env_vars-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dae41b55df32c181c9a85047f60d6aa7c426176481609a7de9910d635c8a82c1 |
|
MD5 | c2b887fcfffe3e09502ef3378e8221b0 |
|
BLAKE2b-256 | 3027613624f0314c1d2cd8ee452c6a1561b329225f21355c7ce266b6aae1927b |