python - Making SQLAlchemy records from a list -
fairly new python , new sqlalchemy. wondering how can use for loop make multiple sqlalchemy records list. here's simplified version of have.
class listitem(base): __tablename__ = list_items id = column(integer, primary_key=true) item = column(string(50)) def list_to_listitem(list_of_things): thing in list_of_things: listitem = listitem() listitem.item = thing i haven't yet run because there's lot more code still needs worked out, i'm under impression that, instead of creating record in list_items each thing in list_of_things, create 1 record assigned listitem overwrite every iteration of loop.
so how do this? said, i'm new python, i've heard factory functions don't understand which, @ least in name, sounds promising problem. in advance!
list_items = [listitem(item=thing) thing in list_of_things]
Comments
Post a Comment