summary refs log tree commit diff
path: root/db.py
blob: de28d7a8d827e8124625a3267ae6dc5beaf5f140 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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"]