This commit is contained in:
KasaNick
2026-01-24 04:26:02 -05:00
parent 4298368b63
commit 9ac637cb41
9 changed files with 581 additions and 23 deletions

View File

@@ -0,0 +1,21 @@
import os
from pymongo import MongoClient
from dotenv import load_dotenv
script_dir = os.path.dirname(os.path.abspath(__file__))
env_path = os.path.join(script_dir, '..', 'rag', '.env')
load_dotenv(env_path)
def get_database():
uri = os.getenv("MONGO_URI")
try:
client = MongoClient(uri)
db = client["my_rag_app"]
print("SUCCESS: Connected to MongoDB Atlas!")
return db
except Exception as e:
print(f"ERROR: Could not connect to MongoDB: {e}")
return None
if __name__ == "__main__":
get_database()