Invalid SQLite URL: sql alchemy python

Viewed 348

trying to follow a tutorial and unsure where I am going wrong. I have tried walking through this multiple times and I'm really drawing a blank. Hopefully someone can point a beginner in the correct direction.

from flask import Flask,render_template,url_for,flash,redirect
from flask_sqlalchemy import SQLAlchemy
import os
basedor = os.path.abspath(os.path.dirname(__file__))

class Config(object):
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATEBASE_URL') or 'sqlite:///' + os.path.join(basedir, 'app.db')
    SQLALCHEMY_TRACK_MODIFICATION = False
    POST_PER_PAGE = 3

app = Flask(__name__)
app.config['SECRET_KEY'] = SECRET_KEY
app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
db=SQLAlchemy(app)

class User(db.Model):
    id=db.Column(db.Integer, primary_key=True)
    username=db.Column(db.String(120), nullable=False)
    password=db.Column(db.String(60), nullable=False)

    def __repr__(self):
     return f"User('{self.username}')"

The error I am getting is below, I know this is because of the location. Some guidance would be superb.

File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\dialects\sqlite\pysqlite.py", line 466, in create_connect_args raise exc.ArgumentError( sqlalchemy.exc.ArgumentError: Invalid SQLite URL: sqlite://app.db

0 Answers
Related