I am using the Redis client for Python called Redis-py. The GitHub library is located here https://github.com/andymccurdy/redis-py. I was wondering if there was any way to set the Redis database initialization values at runtime. For example, if I have a global variable called db
and I want to change the value of db
based on the configuration (dev, test, prod, etc), is there any way I can do this. Redispy only provides a constructor, but doesn't provide any way to initialize at runtime.
One way to do this is define the global variable db
to be None and use a function to set change the db
variable to the correct redis db. But, I am really trying to avoid using the global
keyword/changing a global variable in a function. What are some other ways of doing this?