first time poster, learning python at school.
I am building a flask app and trying to set up a database using SQLalchemy. When I run the app the database is created but has no structure(tables).
my app.py looks like this:
from flask import Flask, render_template,
from flask_sqlalchemy import SQLAlchemy
from model import *
app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI']= 'sqlite:///app.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS']=False
db = SQLAlchemy(app)
db.init_app(app)
db.create_all()
my model.py looks like this:
from datetime import datetime
import db
class Post(db.Model):
id=db.column(db.interger(), primary_key=True)
title=db.column(db.string(225),nullable=False)
slug=db.column(db.string(225), nullable=False)
content=db.column(db.text(), nullable=False)
created_on = db.column(db.DateTime(), default=datetime.utcnow)
updated_on=db.column(db.DateTime(), default=datetime.utcnow, onupdate=datetime )
I believe the database is not connected to the model.py file.