All Projects → klen → marshmallow-peewee

klen / marshmallow-peewee

Licence: MIT License
Peewee ORM integration with the marshmallow (de)serialization library.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to marshmallow-peewee

Marshmallow Jsonapi
JSON API 1.0 (https://jsonapi.org/) formatting with marshmallow
Stars: ✭ 203 (+275.93%)
Mutual labels:  marshmallow
swagger-marshmallow-codegen
generating marshmallow's schema from swagger definition file
Stars: ✭ 51 (-5.56%)
Mutual labels:  marshmallow
apiflask
A lightweight Python web API framework.
Stars: ✭ 442 (+718.52%)
Mutual labels:  marshmallow
MPContribs
Platform for materials scientists to contribute and disseminate their materials data through Materials Project
Stars: ✭ 30 (-44.44%)
Mutual labels:  marshmallow
hidethisbot
An inline Telegram bot to keep your private messages hidden from prying eyes.
Stars: ✭ 44 (-18.52%)
Mutual labels:  peewee
marshmallow-objects
Marshmallow Objects and Models
Stars: ✭ 37 (-31.48%)
Mutual labels:  marshmallow
Marshmallow Jsonschema
JSON Schema Draft v7 (http://json-schema.org/) formatting with marshmallow
Stars: ✭ 172 (+218.52%)
Mutual labels:  marshmallow
kaishnik-bot
telegram & vk bot for students of KNRTU-KAI to make their daily routine more pleasant
Stars: ✭ 13 (-75.93%)
Mutual labels:  peewee
djburger
Framework for safe and maintainable web-projects.
Stars: ✭ 75 (+38.89%)
Mutual labels:  marshmallow
instant api
Instantly create an HTTP API with automatic type conversions, JSON RPC, and a Swagger UI. Just add methods!
Stars: ✭ 115 (+112.96%)
Mutual labels:  marshmallow
stock reminder bot
A twitter bot that reminds you of stock and crypto predictions
Stars: ✭ 25 (-53.7%)
Mutual labels:  peewee
marshmallow-validators
Use 3rd-party validators (e.g. from WTForms and colander) with marshmallow
Stars: ✭ 24 (-55.56%)
Mutual labels:  marshmallow
desert
Deserialize to objects while staying DRY
Stars: ✭ 136 (+151.85%)
Mutual labels:  marshmallow
Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+5131.48%)
Mutual labels:  marshmallow
flask-stupe
💉 a.k.a. « Flask on steroids »
Stars: ✭ 30 (-44.44%)
Mutual labels:  marshmallow
Django Rest Marshmallow
Marshmallow schemas for Django REST framework
Stars: ✭ 198 (+266.67%)
Mutual labels:  marshmallow
EasyPermissions
Request permissions from anywhere as long as you have context.
Stars: ✭ 39 (-27.78%)
Mutual labels:  marshmallow
CustomPermissionsDialogue
Custom Permissions Dialogue is the only permissions library that supports ALL permission request scenarios. This library handles multiple edge cases such as not enabling all permissions or permanently rejecting a permission request.
Stars: ✭ 51 (-5.56%)
Mutual labels:  marshmallow
reactant
Generate code for "models, views, and urls" based on Python type annotations. Supports Django REST, SQLAlchemy, Peewee.
Stars: ✭ 14 (-74.07%)
Mutual labels:  peewee
yt2audiobot
Telegram bot for converting YouTube videos to mp3
Stars: ✭ 26 (-51.85%)
Mutual labels:  peewee

Marshmallow-Peewee

Marshmallow-Peewee -- Peewee ORM integration with the Marshmallow (de)serialization library.

Tests Status PYPI Version Python Versions

Requirements

  • python >= 3.7

Installation

marshmallow-peewee should be installed using pip:

$ pip install marshmallow-peewee

Quickstart

    import peewee as pw


    class Role(pw.Model):
        name = pw.CharField(255, default='user')


    class User(pw.Model):

        created = pw.DateTimeField(default=dt.datetime.now())
        name = pw.CharField(255)
        title = pw.CharField(127, null=True)
        active = pw.BooleanField(default=True)
        rating = pw.IntegerField(default=0)

        role = pw.ForeignKeyField(Role)


    from marshmallow_peewee import ModelSchema

    class UserSchema(ModelSchema):

        class Meta:
            model = User

    role = Role.create()
    user = User.create(name='Mike', role=role)

    result = UserSchema().dump(user)
    print(result)
    # {'active': True,
    #  'created': '2016-03-29T15:27:18.600034+00:00',
    #  'id': 1,
    #  'name': 'Mike',
    #  'rating': 0,
    #  'role': 1,
    #  'title': None}

    result = UserSchema().load(result)
    assert isinstance(result, User)
    assert result.name == 'Mike'

    from marshmallow_peewee import Related

    class UserSchema(ModelSchema):

        role = Related()

        class Meta:
            model = User

    result = UserSchema().dump(user)
    print(result)
    # {'active': True,
    #  'created': '2016-03-29T15:30:32.767483+00:00',
    #  'id': 1,
    #  'name': 'Mike',
    #  'rating': 0,
    #  'role': {'id': 5, 'name': 'user'},
    #  'title': None}

    result = UserSchema().load(result)
    assert isinstance(result, User)
    assert isinstance(result.role, Role)

Usage

    import peewee as pw


    class Role(pw.Model):
        name = pw.CharField(255, default='user')


    class User(pw.Model):

        created = pw.DateTimeField(default=dt.datetime.now())
        name = pw.CharField(255)
        title = pw.CharField(127, null=True)
        active = pw.BooleanField(default=True)
        rating = pw.IntegerField(default=0)

        role = pw.ForeignKeyField(Role)


    from marshmallow_peewee import ModelSchema

    class UserSchema(ModelSchema):

        class Meta:

            # model: Bind peewee.Model to the Schema
            model = User

            # model_converter: Use custom model_converter
            # model_converter = marshmallow_peewee.ModelConverter

            # dump_only_pk: Primary key is dump only
            # dump_only_pk = True

            # string_keys: Convert keys to strings
            # string_keys = True

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/marshmallow-peewee/issues

Contributing

Development of the project happens at: https://github.com/klen/marshmallow-peewee

License

Licensed under a MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].