user050679
user050679

Reputation: 33

sqlalchemy.exc.StatementError: (builtins.TypeError) Not a boolean value: None

I'm trying to create a web page using Flask which insert's data in to a postgresql table BkpFulfilmentProductProvider,but when I do that through web page I get below error.

Can you please advice what could be the issue.

Thanks in advance

Error:

sqlalchemy.exc.StatementError: (builtins.TypeError) Not a boolean value: None
[SQL: INSERT INTO bkp_fulfilment_product_provider (fulfilment_provider_code, is_primary, on_hand_stock, on_order_stock) VALUES (%(fulfilment_provider_code)s, %(is_primary)s, %(on_hand_stock)s, %(on_order_stock)s)]
[parameters: [{'fulfilment_provider_code': (None,), 'on_hand_stock': (None,), 'is_primary': (None,), 'on_order_stock': None}]]

Code :

  @app.route('/')
    def ful():
        return render_template('Ful_Product_Provider.html')
    
    @app.route('/Fulfilment', methods=['POST'])
    def fulfilmentproductprovider():
        from models import BkpFulfilmentProductProvider
        #if request.method == "POST":
        prod_cd = request.form.get('product_code')
        ful_provider_cd = request.form.get('fulfilment_provider_code')
        primary = request.form.get('is_primary')
        stock_in_hand = request.form.get('on_hand_stock')
        ordered_stock = request.form.get('on_order_stock')
    
        fulfil = BkpFulfilmentProductProvider(prod_cd,ful_provider_cd,primary,stock_in_hand,ordered_stock)
        db.session.add(fulfil)
        db.session.commit()
    
        return render_template('Ful_Product_Provider.html')
    

    
    if __name__ == '__main__':
        app.run(debug=True)

Model.py:

class BkpFulfilmentProductProvider(db.Model): """ Databae Model for FUlfilment Product Provider""" tablename = 'bkp_fulfilment_product_provider'

product_code = db.Column(db.String(100), primary_key=True)
fulfilment_provider_code = db.Column(db.String(100))
is_primary = db.Column(db.Boolean)
on_hand_stock = db.Column(db.Integer)
on_order_stock = db.Column(db.Integer)

def __init__(self,product_code,fulfilment_provider_code,on_hand_stock,on_order_stock,is_primary=False):
    self.product_code = product_code
    self.fulfilment_provider_code = fulfilment_provider_code,
    self.is_primary = is_primary,
    self.on_hand_stock = on_hand_stock,
    self.on_order_stock = on_order_stock

Upvotes: 0

Views: 2843

Answers (1)

Dauren Otarbay
Dauren Otarbay

Reputation: 11

There is an extra comma here. fulfilment_provider_code, There should be no comma after it.

Upvotes: 1

Related Questions