This commit is contained in:
Vitaly committed 2023-09-05 14:00:40 +03:00
commit 4716effcf7
309 files changed
+153369

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import os
from pathlib import Path
from dotenv import load_dotenv
import sqlalchemy
import databases
import aioredis
BASE_DIR = Path(__file__).parent.parent.parent
load_dotenv(BASE_DIR.joinpath(".env"))
database = databases.Database(os.environ["DATABASE_URL"].replace("postgresql://", "postgresql+asyncpg://"))
metadata = sqlalchemy.MetaData()
async def get_redis_pool_gen():
redis= await aioredis.from_url("redis://localhost", encoding="utf-8", decode_responses=True)
try:
yield redis
finally:
print("Закрываю редис генератор")
await redis.close()
async def get_redis_pool():
return await aioredis.from_url("redis://localhost", encoding="utf-8", decode_responses=True)