29 lines
837 B
Python
29 lines
837 B
Python
"""Module that provides all database columns"""
|
|
|
|
from async_pymongo import AsyncClient
|
|
from ujson import loads
|
|
|
|
with open("config.json", "r", encoding="utf-8") as f:
|
|
db_config = loads(f.read())["database"]
|
|
f.close()
|
|
|
|
if db_config["user"] is not None and db_config["password"] is not None:
|
|
con_string = "mongodb://{0}:{1}@{2}:{3}/{4}".format(
|
|
db_config["user"],
|
|
db_config["password"],
|
|
db_config["host"],
|
|
db_config["port"],
|
|
db_config["name"],
|
|
)
|
|
else:
|
|
con_string = "mongodb://{0}:{1}/{2}".format(
|
|
db_config["host"], db_config["port"], db_config["name"]
|
|
)
|
|
|
|
db_client = AsyncClient(con_string)
|
|
db = db_client.get_database(name=db_config["name"])
|
|
|
|
col_sent = db.get_collection("sent")
|
|
col_users = db.get_collection("users")
|
|
col_submitted = db.get_collection("submitted")
|