sahilmohile15 0 Light Poster

I have been trying to solve this error for almost 2 days have tried various posts from multiple places like github, stack overflow, and even daniweb. None have helped so far. So expecting atleast explaination for issue if you don't have answer.
So here how I am creating database in connections.py

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
#from app import app
from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)

db = SQLAlchemy(app)

class wreport(db.Model):
    _id = db.Column("id", db.Integer, primary_key=True)
    tname = db.Column("teacher_name", db.String(255))

   def __init__(self,tname):
        self.tname = tname

and I am calling the class in app.py. There is no init.py
app.py

from flask import (Flask, request, redirect, render_template, url_for, session, blueprints, flash)
from flask_sqlalchemy import SQLAlchemy
import config

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///report.sqlite3'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY']= 'Teachers Report'
app.config.from_object(config.DevelopementConfig)

from connection import (db, users, wreport, dreport, students)

db.create_all()
db.session.commit()

#Example of how I am calling the class and trying to pass them
@app.route('/weekly', methods = ["POST", "GET"])
def weekly():
    if request.method == 'POST':
        wreports = wreport(request.form['tname'])
        db.session.add(wreports)
        db.session.commit()

#I am also passing posting the initialization section

db.init_app(app)

if __name__ == "__main__":
    app.run()

I tried calling db.create_all() from the connections.py but it doesn't work either. I am doing proper import of wreport class in app.py.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.