summary refs log tree commit diff
path: root/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'db.py')
-rw-r--r--db.py26
1 files changed, 26 insertions, 0 deletions
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