mirror of
https://github.com/SirBlobby/Hoya26.git
synced 2026-02-04 03:34:34 -05:00
Restore code and save recent updates
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
import os
|
||||
from pymongo import MongoClient
|
||||
from dotenv import load_dotenv
|
||||
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)
|
||||
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
|
||||
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()
|
||||
if __name__ =="__main__":
|
||||
get_database ()
|
||||
Reference in New Issue
Block a user