Skip to content

Commit caee46a

Browse files
committed
Update README
1 parent 6f4c180 commit caee46a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

README.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@ A Simple Example
2929
3030
from flask import Flask
3131
from flask_sqlalchemy import SQLAlchemy
32+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
3233
3334
app = Flask(__name__)
3435
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///example.sqlite"
35-
db = SQLAlchemy(app)
36+
37+
class Base(DeclarativeBase):
38+
pass
39+
40+
db = SQLAlchemy(app, model_class=Base)
3641
3742
class User(db.Model):
38-
id = db.Column(db.Integer, primary_key=True)
39-
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)
4045
4146
with app.app_context():
4247
db.create_all()

0 commit comments

Comments
 (0)