Get proj config args from redis
Project description
config-redis
config-redis is a python library for get project config from redis and don't show your config details in the project.
Installation
1.Use the package manager pip to install Proj_config.
pip install config-redis
2.Install redis-server.
3.Set environment variables from command line.
export CONF_FOR_REDISCONF="{'host': '172.0.0.1', 'port': 6379, 'db': 0, 'password': 'your_password', 'decode_responses': True}" :$CONF_FOR_REDISCONF
Usage
1.setup your config
your_proj/setting.py
from configredis.setconf import devconfig, proconfig, configs, ConfigArgs
con = ConfigArgs()
devconfig(
disk_name="Ten",
sentry=False,
celery_broker="amqp://user:password@172.0.0.1:5672//",
)
proconfig(
sentry=True,
celery_broker="amqp://user:password@172.0.0.1:5672//",
)
config = configs()
2.Use upsert_config_to_redis func update or insert current config to redis. lookup_proj_config func to check the config in redis.
your_proj/setting.py
from configredis.setconf import upsert_config_to_redis, lookup_proj_config
upsert_config_to_redis() # update or insert current config to redis.
print(lookup_proj_config()) # show current project config
3.After write the project config to redis then your can chenge setting.py as below.
your_proj/setting.py
from configredis.setconf import devconfig, proconfig, configs, ConfigArgs
con = ConfigArgs()
devconfig(
disk_name=con['dev']['disk_name'],
sentry=con['dev']['sentry'],
celery_broker=con['dev']['celery_broker'],
)
proconfig(
sentry=con['pro']['sentry'],
celery_broker=con['pro']['celery_broker'],
)
config = configs()
if __name__ == '__main__':
print(config)
4.Run your project as config from command line.
python sample.py pro/dev
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update the tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
config-redis-0.1.3.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for config_redis-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e86ad1c536fb82e25a512b2af1545eb2986bdfbeb4bb5bd15da8fe639ae30827 |
|
MD5 | b9472aa35c566f4c86a385bf5d45b6a5 |
|
BLAKE2b-256 | d1f36aab799edf0095959b9288f6c35aae2cdfb5bd36d7416b14be7104235577 |