Flask-alchemy create Models
Hey Guys and Girls,
I´m wondering about a lot over Tutorials. I´m workin on my first little Flask Web App. I´m a student for Media Tech with intermediate or better good understanding whatsoever.
In many Tutorials this "Mapped" SQLALchemy 2.0 style just does not exist. Why is that? Is there any big difference?
The SQL ALchemy Tutorial tells me to use that style over the old style... I dont get it.
Or it is like Flask-alchemy is using the old style?
# SQL ALCHEMY 2.0 STYLE
class Base(DeclarativeBase):
pass
db = SQLAlchemy(modelclass=Base)
class Sailor(Base):
tablename = 'sailor'
id: Mapped[int] = mappedcolumn(primarykey=True)
username: Mapped[str] = mappedcolumn(String(50), nullable=False)
password: Mappedstr = mappedcolumn(String(50), nullable=False)
#S SQL ALCHEMY OLD STYLE
class Sailor(db.base):
tablename = 'sailor'
id = db.Column(db.Integer, primarykey =
/r/flask
https://redd.it/1iac4im
Hey Guys and Girls,
I´m wondering about a lot over Tutorials. I´m workin on my first little Flask Web App. I´m a student for Media Tech with intermediate or better good understanding whatsoever.
In many Tutorials this "Mapped" SQLALchemy 2.0 style just does not exist. Why is that? Is there any big difference?
The SQL ALchemy Tutorial tells me to use that style over the old style... I dont get it.
Or it is like Flask-alchemy is using the old style?
# SQL ALCHEMY 2.0 STYLE
class Base(DeclarativeBase):
pass
db = SQLAlchemy(modelclass=Base)
class Sailor(Base):
tablename = 'sailor'
id: Mapped[int] = mappedcolumn(primarykey=True)
username: Mapped[str] = mappedcolumn(String(50), nullable=False)
password: Mappedstr = mappedcolumn(String(50), nullable=False)
#S SQL ALCHEMY OLD STYLE
class Sailor(db.base):
tablename = 'sailor'
id = db.Column(db.Integer, primarykey =
/r/flask
https://redd.it/1iac4im
Reddit
From the flask community on Reddit
Explore this post and more from the flask community