Intro to Flask

Today, we will be diving into Flask concepts and best practices.

  • First we must import SQLAlchemy.
    from flask_sqlalchemy import SQLAlchemy

class Employee(db.Model):
tablename = ‘soccer_positions’

id = db.Column(db.Integer, primary_key=True)
position1 = db.Column(db.String)
position2 = db.Column(db.String)
position3 = db.Column(db.String)
Enter fullscreen mode
Exit fullscreen mode

When we are creating a table. We always start with an id to keep track of our table columns.As listed above, we use the id.Integer to show that our id can only be a number/integer and not a text. The next line, we give the variable a name and use db.Column. Could you guess what does the db.Column is for. If you guessed that we use this to create another column in the soccer_positions table, you are correct. Just like db.Integer, we use db.String to make sure that our column can only be a string. Take some time and get some practice with the basics. Next we will talk about relationships between tables.


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Eu amd epyc servers. Prior booking for a seamless dining experience.