We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6f4c180 commit caee46aCopy full SHA for caee46a
README.rst
@@ -29,14 +29,19 @@ A Simple Example
29
30
from flask import Flask
31
from flask_sqlalchemy import SQLAlchemy
32
+ from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
33
34
app = Flask(__name__)
35
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///example.sqlite"
- db = SQLAlchemy(app)
36
+
37
+ class Base(DeclarativeBase):
38
+ pass
39
40
+ db = SQLAlchemy(app, model_class=Base)
41
42
class User(db.Model):
- id = db.Column(db.Integer, primary_key=True)
- username = db.Column(db.String, unique=True, nullable=False)
43
+ id: Mapped[int] = mapped_column(db.Integer, primary_key=True)
44
+ username: Mapped[str] = mapped_column(db.String, unique=True, nullable=False)
45
46
with app.app_context():
47
db.create_all()
0 commit comments