Questions tagged [marshmallow]

Marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes. (For Questions about Android Marshmallow use the tag [android-6.0-marshmallow].)

Marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes. See https://marshmallow.readthedocs.io/en/latest/index.html

589 questions
0
votes
1 answer

Flask sql alchemy get child object

When I declare a relationship with SQL-Alchemy, I don't found all the child's data when Marshmallow dumps the object. When Marshmallow deserialize the object, i would like to get my Member object to json not just the Ids. My models : class…
L. Quastana
  • 1,273
  • 1
  • 12
  • 34
0
votes
1 answer

Update row using sqlalchemy, marshmallow and flask?

I am using flask, sqlalchemy and marshmallow, I have a table with data in place and POST, GET and DELETE work fine, I am having a problem to update the entire row by passing data as JSON, I am querying the row by customer column, tried all options…
Gudzo
  • 639
  • 2
  • 8
  • 21
0
votes
0 answers

Hybrid_property with marshmallow

I have the following code: markers = db.relationship("Marker", back_populates="track") @hybrid_property def first_marker(self): if (len(self.markers) > 0) is True: return self.markers[0] return None and using…
3xecutor
  • 101
  • 2
  • 8
0
votes
1 answer

serialize values of aggregate results from sqlalchemy using marshmallow

I am performing a count() and group_by() operation on a table as follows: db.session.query(func.count(Tag.name), Tag.name).group_by(Tag.name).limit(limit) and serialize it using marshmallow: class TagSchema(ma.ModelSchema): class Meta: …
Jibin Mathew
  • 4,816
  • 4
  • 40
  • 68
0
votes
2 answers

Marshmallow: How can I code for my schema to accept fields not in the table but used to filter?

I want to make an API that accepts two date parameters and have that return all results in a database table. I don't want these dates stored anywhere so I can't define them as columns. My table has three columns: id (int), answers(json),…
0
votes
0 answers

How to get network speed in the ADB shell without using iwconfig

i'm trying to get the bit rate using the iwconfig for the wireless wlan0 but it is no getting it and also tried to get with file sys/class/net/wlan0/speed it is also no getting the answer cat sys/class/net/wlan0/speed …
stackblog
  • 1
  • 1
0
votes
1 answer

AttributeError: type object 'User' has no attribute '_query_cls'

User.id was of type postgresql.UUID Message.sender_id was of type postgresql.UUID with foreignkey to User.id. Changed my type to sqlalchemy_util.UUIDType. I had a problem for serializing my foreign key so I set my own JSONEncoder Now everything is…
Altiire
  • 11
  • 1
  • 5
0
votes
2 answers

how to query data inside nested data in flask_sqlalchemy

i using flask_marshmallow here to show out my json response to frontend, i have i table like bellow class PostImgList(db.Model): __tablename__ = 'boat_img_list' id = db.Column(db.Integer, primary_key=True) link = db.Column(db.Text,…
Arian Saputra
  • 356
  • 6
  • 15
0
votes
1 answer

Loading / deserializing object with nested field

I have two sqlalchemy models - ServiceRecord and Service, with a many-to-many relationship, which is resolved via a service_record_services table. I'm trying to deserialize ServiceRecord object, from the following JSON, and to load Service objects…
Alex
  • 111
  • 7
0
votes
3 answers

How to define the same field for load_only and dump_only params at the Marshmallow scheme?

I am trying to build a marshmallow scheme to both load and dump data. And I get everything OK except one field. Problem description (If you understand the problem, you don't have to read this). For load data its type is Decimal. And I used it like…
egvo
  • 1,493
  • 18
  • 26
0
votes
0 answers

REST API filter / sort with flask (and webargs, marshmallow, sqlalchemy)

I'm working on my first flask-classful / sqlalchemy / marshmallow REST API. I have a Delivery table in my database with a status enum: new requested dispatched arrived closed As expected, GET /deliveries/ returns a list of deliveries. Here's a…
antgel
  • 1,241
  • 1
  • 14
  • 29
0
votes
2 answers

marshmallow-jsonapi: How to reuse schema but change the `type_`?

I have many endpoints but they use the same jsonapi schema. POST /foods { "data": { "type": "food", "attributes": { "name": "abc", "item": "food" } } } POST /chats { "data": { …
drum
  • 5,416
  • 7
  • 57
  • 91
0
votes
1 answer

Customising the ID used in Marshmallow URLFor

I am using a Sqlite database, and flask, marshmallow, sqlalchemy to serve as a web api for a front end project. I'm using a UUID stored as a blob in the database, and trying to stylise the data when its returned to the calling code. I can convert…
Marcus S
  • 103
  • 8
0
votes
1 answer

iterating over objects in a dict to serialize and print using marshmallow

Receiving the following error when trying to iterate over objects as values in a dict, and passing those objects to schema.dump(dev_obj) to be printed. TypeError: dump() missing 1 required positional argument: 'obj' Successfully able to dump and…
0
votes
1 answer

load_only, dump_only for Nested fields

Is there any way in marshmallow-sqlalchemy to specify load_only or dump_only fields for Nested (foos) when serializing/deserializng Bar? class FooSchema(BaseSchema): class Meta(BaseSchema.Meta): model = Foo fields = ('id',…
maslak
  • 1,115
  • 3
  • 8
  • 22