https://github.com/akmamun/quart-pymngo
Asynchronous Python with Quart and Mongo DB Boilerplate
https://github.com/akmamun/quart-pymngo
asyncio boilerplate custom-validation motor pymongo quart rest-api
Last synced: about 2 months ago
JSON representation
Asynchronous Python with Quart and Mongo DB Boilerplate
- Host: GitHub
- URL: https://github.com/akmamun/quart-pymngo
- Owner: akmamun
- License: mit
- Created: 2019-11-01T17:53:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-06T17:39:00.000Z (over 5 years ago)
- Last Synced: 2025-02-10T23:36:26.120Z (3 months ago)
- Topics: asyncio, boilerplate, custom-validation, motor, pymongo, quart, rest-api
- Language: Python
- Homepage:
- Size: 230 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Model Based Restful Quart and Mongo DB
![]()
### Note: API Integration with React [react-api-integration](https://github.com/mrxmamun/react-api-integration.git)
#### Model based restful quart (python) and asynchronous mongo db. Integrate with any API development.### Create [virtual environment]('https://docs.python.org/3/library/venv.html) and install requirements
```sh
pip install -r requirements.txt
```
### Configure Database
#### From [config.py](src/config.py) configure datbase url, name, user and password
```json
{
"db": {
"url" : "mongodb://localhost:27017/",
"name" :"db_name",
"user" :"",
"password" :""
}
}
```## In model update collection name and desire fields name and fields type. For example see todo [model](src/models/todo.py) file
#### From [model](src/models) folder write your individual model and configure db collection name, fields name and fields type
#### Example
##### In todo [model](src/models/todo.py) update collection name, fields name and fields type
```py
collection_name = 'todos' # collection name
fields = {
"title" : "string",
"body" : "string",
"created" : "datatime"
}
```##### Update required fields, optional fields from todo [model](src/models/todo.py)
```py
create_required_fields = [] # example create_required_fields = ["title", "body"]
create_optional_fields = [] # example create_required_fields = ["created"]
update_required_fields = []
update_optional_fields = []
```
#### Example
```py
create_required_fields = ["title", "body"]
create_optional_fields = []
update_required_fields = ["title", "body"]
update_optional_fields = []
```
#### In [Database](src/factory/database.py) insert, find , find_by_id, update and delete methods are generalize methods.
#### Those methods are call from [model](src/models)
- `insert` method store data to database after confirm validation from model
- `find` method retries all data from mongo database
- `find_by_id` method retries back a single search data
- `update` method store updated data to database with corresponding id
- and `delete` method delete data from database with corresponding id### Lets run the App
```sh
python app.py
```