From d9b1580e853978f322a1bf7dee910eb1077e3d46 Mon Sep 17 00:00:00 2001 From: meltland Date: Fri, 7 Mar 2025 23:41:45 -0500 Subject: Initial commit --- db.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db.py (limited to 'db.py') diff --git a/db.py b/db.py new file mode 100644 index 0000000..de28d7a --- /dev/null +++ b/db.py @@ -0,0 +1,26 @@ +import json +import os +from passlib.hash import scrypt +from pymongo.mongo_client import MongoClient +from pymongo.server_api import ServerApi +from dotenv import load_dotenv + +load_dotenv() + +uri = os.getenv("MONGODB_URL") + +# Create a new client and connect to the server +client = MongoClient(uri, server_api=ServerApi('1')) + +# Send a ping to confirm a successful connection +try: + client.admin.command('ping') + print("Connected to MongoDB!") +except Exception as e: + print(e) + exit() + +database = client["SoktDeer"] +postsd = database["Posts"] +usersd = database["Users"] +inboxd = database["Inbox"] \ No newline at end of file -- cgit 1.4.1-2-gfad0