-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.py
More file actions
40 lines (30 loc) · 1.05 KB
/
quickstart.py
File metadata and controls
40 lines (30 loc) · 1.05 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from dotenv import load_dotenv
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi
from app.classes.logging import log_error, log_user_action
from app.database.data.uplinks import uplinks
from app.database.data.downlinks import downlinks
from app.database.data.atc import atcs
# Load environment variables from .env file
load_dotenv()
# Get the URI from environment variable
URI = os.getenv('MONGODB_URI')
client = MongoClient(URI, server_api=ServerApi('1'))
try:
client.admin.command('ping')
log_user_action("-", "mongo_ping_success")
# db = client["datalinks"]
# #uplinks_coll = db["uplinks"]
# downlinks_coll = db["downlinks"]
# #uplinks_coll.drop()
# downlinks_coll.drop()
# # db = client["users"]
# # atc_coll = db["atc"]
# # atc_coll.drop()
# # atc_coll.insert_many(atcs)
# #populate the collections with data
# #uplinks_coll.insert_many(uplinks)
# downlinks_coll.insert_many(downlinks)
except Exception as e:
log_error(None, "mongo_ping_failed", e)