FlaskFM step 13 import error

I’m having trouble with this ( ImportError: cannot import name ‘db’ ) is there some sort of spelling error that I am missing or something ? Here is the code that i have so far


from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) #set the SQLALCHEMY_DATABASE_URI key app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SECRET_KEY'] = 'you-will-never-guess' #create an SQLAlchemy object named `db` and bind it to your app app.config['SQLALCHEMY_DATABASE_URI'}='sqlite:///song_library.db' db = SQLAlchemy(app) #a simple initial greeting @app.route('/') @app.route('/index') def greeting(): return render_template('greeting.html') # app name @app.errorhandler(404) def not_found(e): return render_template("404.html") #uncomment the code below here when you are done creating database instance db and models #import routes


from app import app, db #the User model: each user has a username, and a playlist_id foreign key referring #to the user's Playlist class User(db.Model): id = db.Column(db.Integer, primary_key = True) username = db.Column(db.String(50), index = True, unique = True) playlist_id = db.Column(db.Integer, db.ForeignKey('playlist.id')) #representation method def __repr__(self): return "{}".format(self.username) #create the Song model here + add a nice representation method class Song(db.Model): id = db.Column(db.Integer,primary_key=True) artist = db.Column(db.String(50),index=True, unique=False) title = db.Column(db.String(50), index= True,unique=False) n = db.Column(db.Integer, index=False, unique=False) #create the Item model here + add a nice representation method def __repr_(self): return f'{title} by {artist}' #create the Playlist model here + add a nice representation method class Item(db.Model): id = db.Column(db.Integer, primary_key=True) song_id = db.Column(db.Integer, db.Foreignkey(song.id)) class Playlist(db.Model): id = db.Column(db.Integer, primary_key=True) playlist_id =db.Column(db.Integer, db.Foreignkey(Playlist.id)) items = db.relationship(item, backref='playlist', lazy='dynamic')

Hey GhettoCoder651,

You need to fix the closing bracket on the database connection.


Let me know if this resolve your issue!