Learn

Congratulations on writing your first Flask app with database support!

In this lesson, you have learned how to:

  • import Flask-SQLAlchemy and configure your app to support database connections.
  • create your first model representing a table schema using Flask-SQLAlchemy ORM by declaring classes that extend Model
  • specify attributes of database entities by using Column fields
  • set the primary key Column
  • create a one-to-many relationship by using relationship()
  • specify foreign key columns
  • initialize the database according to the declared models by using create_all()
  • create database entries as instances of the declared Flask-SQLAlchemy classes

We added the Annotation model to the app.py file in order to complete our database schema shown in the first exercise of this lesson. Moreover, we demonstrate for you in the browser how to combine the templates and database queries to list all the books we already put in the database for you. In the next lesson, you will learn how to accomplish this yourself! Excited? Let’s go.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?