Flask extension to build REST APIs based on SQLAlchemy models
Project description
Flask-RESTAlchemy
A Flask extension to build REST APIs. It dismiss the need of building Schema classes, since usually all the information needed to serialize an SQLAlchemy instance is in the model itself.
By adding a model to the API, all its properties will be exposed:
class User(Base):
__tablename__ = "User"
id = Column(Integer, primary_key=True)
firstname = Column(String)
lastname = Column(String)
email = Column(String)
password = Column(String)
api = Api(flask_app)
api.add_model(User, "/user")
To change the way properties are serialized, declare only the one that needs a non-default behaviour:
from serialchemy import ModelSerializer, Field
class UserSerializer(ModelSerializer):
password = Field(load_only=True)
api = Api(flask_app)
api.add_model(User, "/user", serializer_class=UserSerializer)
Release
A reminder for the maintainers on how to make a new release.
Note that the VERSION should folow the semantic versioning as X.Y.Z Ex.: v1.0.5
- Create a
release-VERSION
branch fromupstream/master
. - Update
CHANGELOG.rst
. - Push a branch with the changes.
- Once all builds pass, push a
VERSION
tag toupstream
. - Merge the PR.
Project details
Release history Release notifications | RSS feed
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 flask-restalchemy-0.15.0.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8987aee6b337bd702a5f74c100a12940694ea7a0e713338df737dcdde5e6913b |
|
MD5 | 1863f4eb5334c2aa8614dc104f14fd98 |
|
BLAKE2b-256 | 7b295ead9a6e416f2b1b15db248c6079bfdab683938fbcb1a7f75863bd589299 |
Close
Hashes for flask_restalchemy-0.15.0.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9614e7a43159b133648c0026b6a8e92aef33e0c92aa7918934c636743c928af |
|
MD5 | 7af6e3132f2fd66d189001fb2e91dfd9 |
|
BLAKE2b-256 | b30cbc3a28d9c816cce3957672bcf33b47012d6481df959225d405c6eb30d16d |