Converts HTTP URL query string parameters to flask_sqlalchemy query results
Project description
Description
A simple decorator to speed up development using flask_sqlalchemy, place the decorator pass the model and done! it works!
Usage/Examples
Place the @filter_query passing the model as argument and enjoy!
Usage example on users endpoint with Users model:
@users.route('/users', methods=["GET"])
@filter_query(Users)
def get_users(*args, **kwargs):
return make_response(jsonify(kwargs.get('data')), total=kwargs.get('total')), 200)
then you can make a http request passing arguments:
curl --location 'http://127.0.0.1:5000/users?email__like__=%gabriel%&id__eq__=2
response example:
{
"data": [
{
"email": "gabriel.ligoski@gmail.com",
"id": 2,
"username": "ligoski"
}
],
"total": 1
}
currently supported filters:
- gte
- Example:
curl --location 'http://127.0.0.1:5000/users?id__gte__=2
- Example:
- gt
- Example:
curl --location 'http://127.0.0.1:5000/users?id__gt__=2
- Example:
- lte
- Example:
curl --location 'http://127.0.0.1:5000/users?id__lte__=2
- Example:
- lt
- Example:
curl --location 'http://127.0.0.1:5000/users?id__lt__=2
- Example:
- like
- Example:
curl --location 'http://127.0.0.1:5000/users?email__like__=%gabriel%
- Example:
- in
- Example:
curl --location 'http://127.0.0.1:5000/users?email__in__=gabriel.ligoski@gmail.com,admin@gmail.com,teste@hotmail.com
- Example:
- eq
- Example:
curl --location 'http://127.0.0.1:5000/users?id__eq__=2
- Example:
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
File details
Details for the file flask_sqlalchemy_magic_query-0.1.3.2.tar.gz.
File metadata
- Download URL: flask_sqlalchemy_magic_query-0.1.3.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6603e95f1bb3c10618223b5e4b1cfb5472c287a7c60e83f4196b649ffc9e525
|
|
| MD5 |
9d728bd6e5813f392ce03c4153c1d162
|
|
| BLAKE2b-256 |
77f696430deb67696ce5497cdf1a183ea32566dcbe8a0f794cb0fbba28777fa6
|