@mytec: 1.1iter ready for testing
This commit is contained in:
22
backend/app/core/database.py
Normal file
22
backend/app/core/database.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
class Database:
|
||||
client: AsyncIOMotorClient = None
|
||||
|
||||
|
||||
db = Database()
|
||||
|
||||
|
||||
async def get_database():
|
||||
return db.client[settings.DATABASE_NAME]
|
||||
|
||||
|
||||
async def connect_to_mongo():
|
||||
db.client = AsyncIOMotorClient(settings.MONGODB_URL)
|
||||
|
||||
|
||||
async def close_mongo_connection():
|
||||
if db.client:
|
||||
db.client.close()
|
||||
Reference in New Issue
Block a user