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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dca0cfe3228f4e5161c1ce3fc7ee6b7d7ace8ee4ef6534a7d8ae85cc712965d |
|
MD5 | 89aa1f778f2f0e6c4ee5db1792e981eb |
|
BLAKE2b-256 | 7122d8d7ff0c14a47c21e6edb2b017eda21887404a7af3e78dbfb1132e947b3b |
Close
Hashes for py_easy_rest_mongo_motor_repo-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3703ddb253d69095fcb4bcfd4ddf4527b780bb8cb117cb48c8e5c79281e8b86 |
|
MD5 | 93c26d0414319199796950c3639b2c5d |
|
BLAKE2b-256 | 39d6f6c7e1653fe3896b22b7eee55f66afea6b579a53be175c5cb6b398641ab5 |