I want to list the sources of a piece of information. Instead of creating another table with a one to many relation, I tought I'd use the Array type.
To I tried:
app = Flask(__name__)
db = SQLAlchemy(app)
...
class Edge(db.Model):
sources = db.Column(
db.ARRAY(db.String),
default=db.ARRAY(db.String)
)
But adding an edge gives me this error:
ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'ARRAY' [SQL: 'INSERT INTO edges (child_id, parent_id, sources) VALUES (%(child_id)s, %(parent_id)s, %(sources)s'] [parameters: {'child_id': 20, 'parent_id': 26, 'sources': ARRAY(String())}]
I can't find a good tutorial on how to use an array column with a default empty array.
Thanks