Skip to content

Cannot Create Database #163

Description

@JC-Lord

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)

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions