diff options
author | meltland <[email protected]> | 2025-03-07 23:41:45 -0500 |
---|---|---|
committer | meltland <[email protected]> | 2025-03-07 23:41:45 -0500 |
commit | d9b1580e853978f322a1bf7dee910eb1077e3d46 (patch) | |
tree | c27c64effefc3e5828f6e07bf3798d32bffb4ab0 /db.py |
Initial commit
Diffstat (limited to 'db.py')
-rw-r--r-- | db.py | 26 |
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 |