Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class ModelSchemaMeta(SchemaMeta):
@classmethod
def get_fields(mcs, converter, opts, base_fields, dict_cls):
if opts.model is not None:
return converter.fields_for_model(
opts.model,
fields=opts.fields,
exclude=opts.exclude,
include_fk=opts.include_fk,
base_fields=base_fields,
dict_cls=dict_cls,
)
return dict_cls()
class TableSchema(with_metaclass(TableSchemaMeta, ma.Schema)):
"""Base class for SQLAlchemy model-based Schemas.
Example: ::
from marshmallow_sqlalchemy import TableSchema
from mymodels import engine, users
class UserSchema(TableSchema):
class Meta:
table = users
schema = UserSchema()
select = users.select().limit(1)
user = engine.execute(select).fetchone()