0

我的init 函数收到错误消息,但找不到问题

class Character(Base):
  __tablename__ = 'character'

  id = Column(Integer, primary_key=True)
  _info_id = Column(Integer, ForeignKey('character_info.id'))
  _stats_id = Column(Integer, ForeignKey('character_stats.id'))
  _defence_id = Column(Integer, ForeignKey('character_defences.id'))
  _misc_id = Column(Integer)
  _skills_id = Column(Integer)
  _spells_id = Column(Integer)
  _inventory_id = Column(Integer) 

  _info = relationship("Character_Info", backref=backref('character'))
  _stats = relationship("Character_Stats", backref=backref('character'))
  _defences = relationship("Character_Defences", backref=backref('character')

    def __init__(self, _info, _stats, _defences, _misc, _skills, _spells, _inventory):
      self._info = _info
      self._stats = _stats
      self._defences = _defences
      self._misc = _misc
      self._skills = _skills
      self._spells = _spells
      self._inventory = _inventory

我是 sqlalchemy 的新手,所以我不确定我是否也在正确地处理关系。

但问题似乎出在 def init行(我的 cmd 告诉我)

请帮忙

4

1 回答 1

0

您在)此行的末尾缺少 a 。

_defences = relationship("Character_Defences", backref=backref('character')

加上def __init__块没有正确缩进。

于 2013-02-28T00:25:48.793 回答