import os import redis.asyncio as connection REDIS_HOST = os.getenv('REDIS_HOST', 'localhost') REDIS_PASSWORD = os.getenv('REDIS_PASSWORD') if REDIS_PASSWORD: URL = f'redis://:{REDIS_PASSWORD}@{REDIS_HOST}:6379' else: URL = f'redis://{REDIS_HOST}:6379' pool = connection.from_url(URL) database = connection.Redis.from_pool(pool)