This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A marshmallow-sqlalchemy field allows referential CRUD on relational fields.

Project Description

Installation

pip install marshmallow-sqlalchemy-referential

Sample Usage

import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from marshmallow_sqlalchemy_referential import Referential
from marshmallow_sqlalchemy import ModelSchema
from marshmallow import fields

Base = declarative_base()

user_group_assoc = sa.Table(
  'user_group_assoc', Base.metadata,
  sa.Column('user_id', sa.Integer, sa.ForeignKey('user.id')),
  sa.Column('group_id', sa.Integer, sa.ForeignKey('group.id'))
)

class User(Base):
    __tablename__ = 'user'

    id = sa.Column(sa.Integer(), primary_key=True)
    groups = sa.orm.relationship('Group', secondary=user_group_assoc)

class Group(Base):
    __tablename__ = 'group'

    id = sa.Column(sa.Integer(), primary_key=True)
    users = sa.orm.relationship('User', secondary=user_group_assoc)


class GroupSchema(ModelSchema):
  class Meta():
      dump_only = ['id']

  id = fields.Integer()

class UserSchema(ModelSchema):
  class Meta():
      dump_only = ['id']

  id = fields.Integer()
  groups = Referential(GroupSchema, model=Group, many=True)
Release History

Release History

This version
History Node

1.0.5

History Node

1.0.4

History Node

1.0.2

History Node

1.0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
marshmallow-sqlalchemy-referential-1.0.5.tar.gz (3.9 kB) Copy SHA256 Checksum SHA256 Source Sep 8, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting