python - Cant change class on SQLAlchemy -
hello trying change class in sqlalchemy because giving me error, error is:
file "<string>", line 2, in __init__ file "c:\python34\lib\site-packages\sqlalchemy\orm\instrumentation.py", line 324, in _new_state_if_none state = self._state_constructor(instance, self) file "c:\python34\lib\site-packages\sqlalchemy\util\langhelpers.py", line 725, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) file "c:\python34\lib\site-packages\sqlalchemy\orm\instrumentation.py", line 158, in _state_constructor self.dispatch.first_init(self, self.class_) file "c:\python34\lib\site-packages\sqlalchemy\event\attr.py", line 260, in __call__ fn(*args, **kw) file "c:\python34\lib\site-packages\sqlalchemy\orm\mapper.py", line 2693, in _event_on_first_init configure_mappers() file "c:\python34\lib\site-packages\sqlalchemy\orm\mapper.py", line 2589, in configure_mappers mapper._post_configure_properties() file "c:\python34\lib\site-packages\sqlalchemy\orm\mapper.py", line 1694, in _post_configure_properties prop.init() file "c:\python34\lib\site-packages\sqlalchemy\orm\interfaces.py", line 144, in init self.do_init() file "c:\python34\lib\site-packages\sqlalchemy\orm\relationships.py", line 1549, in do_init self._process_dependent_arguments() file "c:\python34\lib\site-packages\sqlalchemy\orm\relationships.py", line 1605, in _process_dependent_arguments self.target = self.mapper.mapped_table file "c:\python34\lib\site-packages\sqlalchemy\util\langhelpers.py", line 725, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) file "c:\python34\lib\site-packages\sqlalchemy\orm\relationships.py", line 1535, in mapper % (self.key, type(argument))) sqlalchemy.exc.argumenterror: relationship 'prod_comm_rel' expects class or mapper argument (received: <class 'sqlalchemy.sql.schema.column'>) but never change error keeps comming, class:
class product(base): __tablename__="xxxxxx_reg" __table_args__ = {"useexisting": true} id = column("id",bigint, primary_key=true) name = column("_name",text, nullable=false) code = column("code", bigint, unique=true) status = column("status",bigint, foreignkey(status.code),nullable=false) description = column("description",text, nullable=false) avatar = column("avatar", text, nullable=false) type = column("_type",bigint, foreignkey(type.id),nullable=false) price = column("price",numeric(20,2),nullable=false) costs = column("costs",numeric(20,2),default=0.00) commcode = column("commerce", bigint, foreignkey(commerce.code), nullable=false) #relation prod_status_rel = relationship(status, backref=backref("product")) prod_type_rel = relationship(type, backref=backref("product")) prod_comm_rel = relationship(commerce, backref=backref("product")) def __repr__(self): return "<product(id='%s', name='%s', status='%s', description='%s', " \ "type='%s', price='%s', costs='%s', code='%s',commerce='%s')>"%(self.id, self.name, self.status,self.description, self.type, self.price, self.costs, self.code, self.commcode) metadata = metadata() product_tbl = table(__tablename__, metadata,id,name,status,description, type,price, costs, code, commcode) engine = conection().conorm() metadata.create_all(engine) how can fix code, because made change , when run class alone works, problem when try run other parts of codes
Comments
Post a Comment