Last active
October 30, 2020 08:01
-
-
Save MwinyiMoha/e862571d1eac6963368f21ec9aa25ed9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from motor.motor_asyncio import AsyncIOMotorClient as AIOMC | |
DB_NAME = 'fastapi' | |
MONGO_URI = f"mongodb://<user>:<password>@localhost:27017/{DB_NAME}?authSource=admin" | |
todos_db = DB_NAME | |
todos_coll = 'todos' | |
class DB: | |
client: AIOMC = None | |
db = DB() | |
def connect_mongo(): | |
db.client = AIOMC(MONGO_URI) | |
def disconnect_mongo(): | |
db.client.close() | |
def get_database(): | |
return db.client |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment