0

How to add List in Flask Sqlalchemy

I have a list ,which inwant to add it to Flask Sqlalchemy. Example: a = ['a','b'] test = DB(name=a) db.session.add(test) db.session.commit() I am getting error on above code

10th May 2020, 2:09 AM
Prashant Pokhriyal
Prashant Pokhriyal - avatar
2 Answers
0
You are meddling with stuff that seems to be way above your level of knowledge. I am pretty sure you cannot just add a list of strings to a database. Relational databases have tables, which have columns, which have data types. The ORM (Sqlalchemy) helps to define these in Python using object-oriented concepts. If this sounds like greek to you, then you should start with more basic stuff and complete the Python course. Get enough practice to be able to read and understand error messages. Then you can proceed with the Flask documentation. https://flask-sqlalchemy.palletsprojects.com/en/2.x/
10th May 2020, 5:36 AM
Tibor Santa
Tibor Santa - avatar
0
a = ['a','b'] for i in a: test = DB(name=i) db.session.add(test) db.session.commit()
13th Nov 2020, 4:31 AM
Prashant Pokhriyal
Prashant Pokhriyal - avatar