when i try to run this code in python i get the type errors File "/home/codio/workspace/MyProject/app.py", line 8, in class Book(db.Model): File "/home/codio/workspace/MyProject/app.py", line 15, in Book tradePrice = db.Column(db.Integer(length=10), nullable=0) TypeError: object() takes no parameters I am new to flask and im dont understand whats causing this
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy # database library for flask
# using render_template to have the html code in different files
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']= 'sqlite:///books.db' #confgurating a database
db = SQLAlchemy(app)
class Book(db.Model):
barcode = db.Column(db.String(length=12), nullable=0, primary_key=1)
title = db.Column(db.String(length=50), nullable=0, unique=1)
author = db.Column(db.String(length=50), nullable=0)
publicationDate = db.Column(db.String(length=10), nullable=0)
quantity = db.Column(db.Integer(), nullable=0)
description = db.Column(db.String(length=1000), nullable=0)
tradePrice = db.Column(db.Integer(length=10), nullable=0)
retailPrice = db.Column(db.Integer(length=10), nullable=0)
@app.route("/login") # home page
def login_page():
return render_template("login.html")
@app.route("/home")
@app.route("/")
def home_page():
return render_template("home.html")
@app.route("/stock")
def stock_page():
return render_template("stock.html", books=books)