We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 008cd2c commit 646ed1bCopy full SHA for 646ed1b
models.py
@@ -1,13 +1,18 @@
1
"""Define Models used in this example."""
2
from db import Base
3
-from sqlalchemy import Column, Integer, String
+from sqlalchemy import String
4
+from sqlalchemy.orm import Mapped, mapped_column
5
6
7
class User(Base):
8
"""Create a test table."""
9
10
__tablename__ = "users"
11
- id = Column(Integer, primary_key=True, index=True)
12
- name = Column(String)
13
- email = Column(String, unique=True, index=True)
+ id: Mapped[int] = mapped_column(primary_key=True)
+ name: Mapped[str] = mapped_column(String(255))
14
+ email: Mapped[str] = mapped_column(String(120), unique=True, index=True)
15
+
16
+ def __repr__(self) -> str:
17
+ """Define the model representation."""
18
+ return f'User({self.id}, "{self.name}")'
0 commit comments