Mongo repo to use with Py Easy REST
Project description
py-easy-rest-mongo-motor-repo
Cache lib 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.server import App
from py_easy_rest_mongo_motor_repo.mongo_motor_repo import MongoRepo
config = {
"name": "Project Name",
"schemas": [{
"name": "Mock",
"slug": "mock",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name"],
}]
}
repo = MongoRepo()
pyrApp = App(config, repo=repo)
@pyrApp.app.listener('before_server_start')
def init(app, loop):
mongo_db_instance = AsyncIOMotorClient("mongodb://localhost:27017/db")
db = mongo_db_instance.get_default_database()
collection = db["default"]
repo.set_db_collection(collection)
pyrApp.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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1d74c46e242930c0d72d892b4336e0eaa8a76aad7edf2d8a9cdbc289edcd39 |
|
MD5 | 4d733e0797e49d94f68ecf4902b2b55b |
|
BLAKE2b-256 | 109b3e93e76f06be5499b3050e81b2a45f977cc2be768f6454048c3ab6d173ae |
Close
Hashes for py_easy_rest_mongo_motor_repo-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 377a3139520e29776989141785a74352df879d7bff867202fee29a92ce478b74 |
|
MD5 | 60236f125be5ff424aa79f8f3f5d156a |
|
BLAKE2b-256 | 94e7a144580f0872cb57b8768ac795e787ae57a732700182366cd752e3b5e6c0 |