I have a tuple of data:
('dave', 23, 'm'),
('alice', 33, 'f'),
('mary', 44, 'f')
I have an sqlalchemy base class:
class People(Base):
__tablename__='people'
I want to be able to dynamically create columns/fields for this class using data from the tuple above
the end result would be:
class People(Base):
__tablename__='people'
dave = Column(String)
alice = Column(String)
mary = Column(String)
though, i can't figure out how do use the splat operator to create the fields..
name,age, andsexcolumns instead in yourpeopletable, and you'd store the tuples as rows of that table.col['column_name'] = Column(col['type']) for col in columnshttps://stackoverflow.com/questions/2574105/sqlalchemy-dynamic-mapping/2575016#2575016