[Sqlalchemy-tickets] Issue #3838: Class with automap should override all columns? (zzzeek/sqlalchem
Brought to you by:
zzzeek
From: Giorgos P. <iss...@bi...> - 2016-10-25 01:14:28
|
New issue 3838: Class with automap should override all columns? https://bitbucket.org/zzzeek/sqlalchemy/issues/3838/class-with-automap-should-override-all Giorgos Papadrosou: Hi, I have this example: ``` #!python class CarrierGroup(MyBase): __tablename__ = 'carrier_group' group_id = Column(Integer, Sequence('carrier_group_group_id_seq'), primary_key=True) # group_name = Column(String) # commented but exists in DB engine = create_engine('postgresql://...') metadata = MetaData(bind=engine) MyBase = automap_base(metadata=metadata) metadata.reflect(only=exclude_tables) MyBase.prepare(name_for_scalar_relationship=name_for_scalar_relationship) Session = scoped_session(sessionmaker()) session = Session() session.add(CarrierGroup(group_name='testgroup')) ``` This code fails in the last statement with "TypeError: 'group_name' is an invalid keyword argument for CarrierGroup ". Why? If I want to create a Class, do I need to explicitly write all the fields? Thank you |