Coverage for docs_src/sql_databases/sql_app_py39/models.py: 100%
17 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from sqlalchemy import Boolean, Column, ForeignKey, Integer, String 1abcd
2from sqlalchemy.orm import relationship 1abcd
4from .database import Base 1abcd
7class User(Base): 1abcd
8 __tablename__ = "users" 1abcd
10 id = Column(Integer, primary_key=True) 1abcd
11 email = Column(String, unique=True, index=True) 1abcd
12 hashed_password = Column(String) 1abcd
13 is_active = Column(Boolean, default=True) 1abcd
15 items = relationship("Item", back_populates="owner") 1abcd
18class Item(Base): 1abcd
19 __tablename__ = "items" 1abcd
21 id = Column(Integer, primary_key=True) 1abcd
22 title = Column(String, index=True) 1abcd
23 description = Column(String, index=True) 1abcd
24 owner_id = Column(Integer, ForeignKey("users.id")) 1abcd
26 owner = relationship("User", back_populates="items") 1abcd