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.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()
repo.set_db_connection(db)
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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3506662c2be2c550a8b1d4b03143035a10e18ae4700ac4ae48d2506e877ea039 |
|
MD5 | ab06fe3303429b3f1411cbb343bcb92e |
|
BLAKE2b-256 | e731705e0a75e34d0684120df7dc905775671aa7b31b61c73e8544626e67a8bb |
Close
Hashes for py_easy_rest_mongo_motor_repo-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff1db6a36571bbcc56f6bbcbfcdadb776a9bef230040feb83d48f82614520c46 |
|
MD5 | ecda8ad1c1d3a5f8a14e4fa883f2ae29 |
|
BLAKE2b-256 | 010252d20b981df844d0f921fb97c6144a516c59b8b34a5a2f7bb82fa17fe398 |