Creating a Mutable Array data type in sqlalchemy
The problem with using the ARRAY datatype in sqlalchemy is that it’s immutable. This means it isn’t possible to add new data into array once it has been initialised. Unfortunately, I couldn’t find any good solution to create mutable arrays until I came across this snippet by Michael Bayer, the author of sqlalchemy himself:
|
|
What this snippet allows you to do is to extend a list to add mutability to it. So, now you can use the class above to create a mutable array type like so:
|
|