Flask db array

I want to create an editable array in Flask-SQLite. I have one ingredient which is used in many different recipes, so I want to have the following structure:

class IngredientsModel(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String, index = True, unique = True)
    recipes = db.Column(db.PickleType(mutable = True))
    def addRecipeTitle(self, recipeTitle):

    def calculateRecipeTitles(self):
        return len(self.recipes)

    def __repr__(self):
        return '{name} appears in {numberOfRecipes}'.format(name=self.name, numberOfRecipes=calculateRecipeTitles(self))

The problem though is that I get this error when trying to initialize a class instance:

TypeError: __init__() got an unexpected keyword argument 'mutable'

Traceback (most recent call last)
File "C:\Users\Денис\Documents\Coding\Projects\Web development\Web application\Flask + React\flask-back-end\app.py", line 113, in <module>
class IngredientsModel(db.Model):
File "C:\Users\Денис\Documents\Coding\Projects\Web development\Web application\Flask + React\flask-back-end\app.py", line 116, in IngredientsModel
recipes = db.Column(db.PickleType(mutable = True))
TypeError: __init__() got an unexpected keyword argument 'mutable'
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object

Any help would be appreciated!

I’d look into models that look like student-classes (many to many). I haven’t done it in a bit so I’m rusty but the way I do it is to have an student class, a “course” class, and a registrations table that links the relationships of the two together. I feel like this could be used in this scenario if I’m understanding your schema correctly.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.