Questions tagged [marshmallow-sqlalchemy]
54 questions
5
votes
1 answer
"Unknown field" after updating to 3.5.0 marshmallow
Updated dependency in my project
Before
marshmallow-sqlalchemy==0.17.0
marshmallow==3.0.0b6
After
marshmallow-sqlalchemy==0.21.0
marshmallow==3.5.0
I have such a model (simplified):
from sqlalchemy.ext.declarative import declarative_base
Base =…

Vova
- 580
- 3
- 7
- 20
4
votes
2 answers
sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.dict' is not mapped
I'm trying to insert a new User into a DB using SQLAlchemy and Marshmallow. The user parameter is received from an API endpoint. Everything works until I get to this line in the create function:
db.session.add(new_user)
The value of the new_user…

Aeross
- 302
- 2
- 3
- 12
4
votes
2 answers
How to get Marshmallow-Sqlalchemy to Sort by an Association Object Field?
How can I get Marshmallow to sort the returned dataset––by a field in the association object (seat_index)? The end result is to sort a bunch of classroom objects by class start time, and then by student seat index.
I'm looking for something…

grahama
- 321
- 4
- 13
3
votes
2 answers
Dynamically generating marshmallow schemas for SQLAlchemy fails on column attribute lookup for Relationship
I am automatically deriving marshmallow schemas for SQLAlchemy objects using the approach described in How to dynamically generate marshmallow schemas for SQLAlchemy models.
I am then decorating my model classes:
@derive_schema
class Foo(db.Model):
…

Yuval Itzchakov
- 146,575
- 32
- 257
- 321
3
votes
1 answer
SQLAlchemyAutoSchema Nested Deserialization
I have the following:
Models.py
class Policy(db.Model):
policy_id = db.Column(db.Integer, primary_key=True)
client_reference = db.Column(db.String(50), nullable=False)
submission_id = db.Column(db.ForeignKey('submission.submission_id'),…

simon_dmorias
- 2,343
- 3
- 19
- 33
2
votes
0 answers
Prevent marshmallow from querying the db
I want to completely prevent marshmallow from querying the db.
Below the explanatory code snippet
from flask_sqlalchemy import SQLAlchemy
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
from flask_restful import Resource
db =…

Rukamakama
- 780
- 1
- 8
- 16
2
votes
0 answers
Sum felds with with sqlalchemy and marshmallow
I'm using the python's framework pyramid, sqlalchemy for the data and marshmallow to serialize.
I'm want to send a sum of value to the client
I have Challenge and player whom use this challenge, each actions of the player is an event and each…

MarilynS
- 41
- 3
2
votes
1 answer
How to handle the __init__function by using dataclass, Sqlalchemy and marshmallow_sqlalchemy
In the current stable version of SQLAlchemy there is no method to map the Model to a data class (which is supposed to be available in v1.4). So I want to apply the ORM my self by defining:
class User(db.Model):
__tablename__ = "users"
id =…

robin
- 21
- 4
2
votes
1 answer
Deserialize list of ids for many-to-many PUT operation
I have a User and Role model with a many-to-many relationship
class User(BaseModel, TimestampableMixin):
username = Column(String(MEDIUM_STRING_LENGTH), nullable=False, unique=True)
roles = relationship('Role', secondary='user_roles',…

Casey
- 395
- 1
- 2
- 8
1
vote
1 answer
AttributeError: 'dict' object has no attribute
I'm trying to use sqlalchemy and marshmallow to make an PUT endpoint to update some data in a model. I'm running into this error:
File "/Users/ronak.patel/MLGit/pythonAPI/applications.py", line 129, in update
update.applicationId =…

lightweight
- 3,227
- 14
- 79
- 142
1
vote
0 answers
Python: marshmallow doesn't return backref column data
I have two tables as below where SupplierCompany has a relationship with Office and has a backref column referenced in the Office table:
class Office(BaseModel):
__tablename__ = 'offices'
id = db.Column(db.Integer, primary_key=True)
…

Omar Abdelrazik
- 683
- 2
- 9
- 30
1
vote
1 answer
Getting foreign key instead of relationship table in marshmallow_sqlalchemy schema
I have a flask-sqlalchemy table composed of a relationship with 4 other tables as follows:
office_cardgroups = db.Table('office_cardgroups',
db.Column('officedata_id', db.Integer, db.ForeignKey('officedata.id')),
…

Omar Abdelrazik
- 683
- 2
- 9
- 30
1
vote
0 answers
Is there a way to model multiple objects using marshmallow sqlAlchemy?
I have the following SqlAlchemy configuration (pseudo code for brevity):
class A(BaseModel):
id: column...
b_id: column...
b: relationship...
class B(BaseModel):
id: column...
name: column...
class C(BaseModel):
id: column...
…

Jelkimantis
- 138
- 1
- 10
1
vote
0 answers
Can you map a table valued function to a declaritive base using SQLAlchemy
I'm in a situation where the data I want to access is using Table Valued Functions in SQL Server.
The app I'm building already interfaces with regular tables using SQLAlchemy ORM and the declarative_base(). Those are then parsed using…

PatientSnake
- 40
- 6
1
vote
1 answer
marshmallow - include_fk fail if foreign_key is not int
On serializing a related database entity with sql-alchemy and marshmallow I encountered following issue:
On dumping this schema the debugger raises a ValueError with the message
self._serialize(d, many=False)
value =…

voltae
- 582
- 4
- 11