I am admittedly extremely new to Python and coding in general, however, I was following along with this tutorial a day ago and everything was going well up until it came time to create the database.
My code is as follows:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from os import path'
from .views import views
from .auth import auth
app.register_blueprint(views, url_prefix='/')
app.register_blueprint(auth, url_prefix='/')
from .models import User, Note
with app.app_context():
db.create_all()
return app
def create_database(app):
if not path.exists('website/' + DB_NAME):
db.create_all(app=app)
print('Created Database!')
I have looked over stack overflow and tried a few things here and there, however, I just seem to run into more errors.
At one point what seemed like a database was created in the instance folder of my project, however, it was not named what was expected and I have since been unable to replicate its creation.
I am admittedly extremely new to Python and coding in general, however, I was following along with this tutorial a day ago and everything was going well up until it came time to create the database.
My code is as follows:
from flask import Flask from flask_sqlalchemy import SQLAlchemy from os import path'
db = SQLAlchemy() DB_NAME = "database.db"
def create_app(): app = Flask(name) app.config['SECRET_KEY'] = 'domine' app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}' db.init_app(app)
def create_database(app): if not path.exists('website/' + DB_NAME): db.create_all(app=app) print('Created Database!')
I have looked over stack overflow and tried a few things here and there, however, I just seem to run into more errors. At one point what seemed like a database was created in the instance folder of my project, however, it was not named what was expected and I have since been unable to replicate its creation.