Mongo repo to use with Py Easy REST
Project description
py-easy-rest-mongo-motor-repo
Mongo repo to use with py-easy-rest
Getting Started
How to install
pip install py-easy-rest py-easy-rest-mongo-motor-repo
Integrating with your py-easy-rest app
Mongo Repository
#main.py
from motor.motor_asyncio import AsyncIOMotorClient
from py_easy_rest import PYRSanicAppBuilder
from py_easy_rest.service import PYRService
from py_easy_rest_mongo_motor_repo import PYRMongoRepo
config = {
"name": "Project Name",
"schemas": [{
"name": "Mock",
"slug": "mock",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name"],
}]
}
repo = PYRMongoRepo()
service = PYRService(api_config_mock, repo=repo)
sanic_app = PYRSanicAppBuilder.build(api_config_mock, service)
@sanic_app.listener('before_server_start')
def init(app, loop):
mongo_db_instance = AsyncIOMotorClient("mongodb://localhost:27017/db")
db = mongo_db_instance.get_default_database()
repo.set_db_connection(db)
sanic_app.run(
host='0.0.0.0',
port=8000,
debug=True,
auto_reload=True,
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for py-easy-rest-mongo-motor-repo-0.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49b25edc24bf3c48724901d2f36a91d0ef43ebc32acee16713ad4ac0f14c5354 |
|
MD5 | ad1a5538fe730441d4fce75064356ed7 |
|
BLAKE2b-256 | ad971733a98d8be7e77288a72f85f874eb66aac2bb519dc68927cbd62651cddc |
Close
Hashes for py_easy_rest_mongo_motor_repo-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9a60c6a1ed81cdae321be5aeaec69f6e9d18d0457c6a5a9087494dca2986470 |
|
MD5 | 7cb3546d34010660fcf7314e8e0ed64f |
|
BLAKE2b-256 | 0a0766c6aa142b8ea1f344a661cc2fd900e9481a368f2957909384e474b2cad7 |