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
File details
Details for the file flask-restalchemy-0.14.1.tar.gz
.
File metadata
- Download URL: flask-restalchemy-0.14.1.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6648ae2590c7c1f1bdffa1a7acd263ab2fbc96b8143307e3d810aae01696bf0f |
|
MD5 | 07f5500faa0a038c16f340c95c4d7a66 |
|
BLAKE2b-256 | 7f7ed85ded2efd36b93e720f4c02133c952ee293a3a40c1d86706f44d53a275d |
File details
Details for the file flask_restalchemy-0.14.1-py3-none-any.whl
.
File metadata
- Download URL: flask_restalchemy-0.14.1-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72c638c47f61f38fbeae228c87e7aa7b0c092f706163d43983b282763a8bf509 |
|
MD5 | baed2db1c55e19f3e17cdca04e5f53a0 |
|
BLAKE2b-256 | 058fc10cff11a9f62fee2657c055041626d2ef204366c52a6326ae925a3d084f |