Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from mymodels import engine, users
class UserSchema(TableSchema):
class Meta:
table = users
schema = UserSchema()
select = users.select().limit(1)
user = engine.execute(select).fetchone()
serialized = schema.dump(user).data
"""
OPTIONS_CLASS = TableSchemaOpts
class ModelSchema(with_metaclass(ModelSchemaMeta, ma.Schema)):
"""Base class for SQLAlchemy model-based Schemas.
Example: ::
from marshmallow_sqlalchemy import ModelSchema
from mymodels import User, session
class UserSchema(ModelSchema):
class Meta:
model = User
schema = UserSchema()
user = schema.load({'name': 'Bill'}, session=session)
existing_user = schema.load({'name': 'Bill'}, instance=User.query.first())