[Tutor] Error with sqlalchemy

rakesh sharma rakeshsharma14 at hotmail.com
Tue Aug 1 07:13:25 EDT 2017


Hi All


I am getting an error in python. Its a flask app that I am doing

I am getting the error

TypeError: utf_8_decode() argument 1 must be string or buffer, not long

at this point in the code

ship_schedules = ShipSchedule.query.all()

The schema definition is like that I gave below, there is no mismatch between the schema and the table definition in the mysql DB.

class ShipSchedule(Base):

    __tablename__ = 'ship_schedule'

    vessel_imo_no = Column(Integer, primary_key=True, nullable=False)
    commodity_product_code = Column(String, nullable=False)
    port_port_code = Column(String, nullable=False)
    cargo_quantity = Column(String, nullable=False)
    activity = Column(String, nullable=False)
    date_from = Column(Date, nullable=False)
    date_to = Column(Date, nullable=False)


"""
    Ship schedule schema
"""


class ShipScheduleSchema(Schema):
    vessel_imo_no = fields.Int(dump_only=True)
    commodity_product_code = fields.Str()
    port_port_code = fields.Str()
    cargo_quantity = fields.Int()
    activity = fields.Str()
    date_from = fields.Date()
    date_to = fields.Date()

the mysql table defintion is as follows


[cid:e101f2ac-60ca-426a-8e53-01afd9e9414d]


please help on this, do not know the whats causing the issue.

I dint find any good answers in stackoverflow as all points to schema mismatch

thanks

rakesh


More information about the Tutor mailing list