What model should a SQLalchemy database column be to contain an array of data? What model should a SQLalchemy database column be to contain an array of data? flask flask

What model should a SQLalchemy database column be to contain an array of data?


If you really want to have a python list as a Column in SQLAlchemy you will want to have a look at the PickleType:

array = db.Column(db.PickleType(mutable=True))

Please note that you will have to use the mutable=True parameter to be able to edit the column. SQLAlchemy will detect changes automatically and they will be saved as soon as you commit them.

If you want the pickle to be human-readable you can combine it with json or other converters that suffice your purposes.