File size: 369 Bytes
791f9f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from motor.motor_asyncio import AsyncIOMotorClient
import os
from dotenv import load_dotenv

load_dotenv()

MONGODB_URI = os.getenv("MONGODB_URI")
MONGODB_DB = os.getenv("MONGODB_DB")

if not MONGODB_URI:
    raise ValueError("MONGODB_URI not set in environment variables")

client = AsyncIOMotorClient(MONGODB_URI)
db = client[MONGODB_DB]

def get_db():
    return db