sqlalchemy def __init__ syntaxerror

时间:2013-02-28 00:24:04

标签: python syntax sqlalchemy init

我的 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告诉我)

请帮忙

1 个答案:

答案 0 :(得分:0)

你在这一行的末尾错过了)

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

另外,def __init__块没有正确缩进。