I'm learning to develop a web app with flask but now I'm stuck with this error using flask-sqlalchemy:
Original exception was: (InterfaceError) Error binding parameter 0 - probably unsupported type.
u'INSERT INTO standards (std_insumo_id, std_name_id, cantidad, viviendas) VALUES (?, ?, ?, ?)' (...)",))
These are my models
class Insumo(db.Model):
__tablename__ = 'insumos'
codigo = db.Column(db.Integer, primary_key=True)
descripcion = db.Column(db.String(64), unique=True)
um = db.Column(db.String(64))
class StandardName(db.Model):
__tablename__ = 'std_names'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), unique=True)
standards = db.relationship('Standard', backref='std_name')
class Standard(db.Model):
__tablename__ = 'standards'
id = db.Column(db.Integer, primary_key=True)
std_insumo_id = db.Column(db.Integer, db.ForeignKey('insumos.codigo'))
std_name_id = db.Column(db.Integer, db.ForeignKey('std_names.id'))
cantidad = db.Column(db.Float)
viviendas = db.Column(db.Integer)
And this is what i'm doing when im trying to insert the row:
cemento = Insumo.query.filter_by(descripcion="Cemento").first()
mamp = StandardName.query.filter_by(name="Mamposteria").first()
These two already exist in the db, so there is no problem. The problem arises when I'm trying to use model: Standard
r1 = Standard(std_insumo_id=cemento, std_name_id=mamp, cantidad=10, viviendas=40)
db.session.add(r1)
db.session.commit()
Could you help me understand what is happening? I don't see anything wrong with the types.