Skip to content Skip to sidebar Skip to footer

Flask Sqlarchemy, Html: Valueerror: Not Enough Values To Unpack (expected 2, Got 1)

I am executing the command flask migrate to create the referring tables more at the moment it starts to run, even though it identifies the tables, it throws the following error. I

Solution 1:

I am running into the same error. In my case the error disappears if I remove the table_args . Then the migration works so I think it has probably to do with the ForeignKey constraints.

class AccommodationAirport(db.Model):
    __tablename__ = 'accommodation_airport'
    __table_args__ = (
        ForeignKeyConstraint(
        ['supplier'], ['accommodation'],
        name='fk_acco_airp_sup_acco'
        ),
        UniqueConstraint(
            'supplier', 'accommodation', 'airport',
            name='uq_sup_acco_airp'
        )
    )
    created = db.Column(db.DateTime, server_default=func.now())
    last_modified = db.Column(db.DateTime, onupdate=func.now())
    modified_by = db.Column(db.Integer)
    supplier = db.Column(db.String(8), primary_key=True)
    accommodation = db.Column(db.String(32), primary_key=True)
    airport = db.Column(db.String(3), primary_key=True)
    

The only solution I have found so far is to

  1. comment out the table_args with the Constraint declarations,
  2. migrate -> upgrade
  3. uncomment the table_args
  4. migrate -> upgrade

Post a Comment for "Flask Sqlarchemy, Html: Valueerror: Not Enough Values To Unpack (expected 2, Got 1)"