Coverage for docs_src/sql_databases/sql_app/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 1abcde
2from sqlalchemy.orm import relationship 1abcde
4from .database import Base 1abcde
7class User(Base): 1abcde
8 __tablename__ = "users" 1abcde
10 id = Column(Integer, primary_key=True) 1abcde
11 email = Column(String, unique=True, index=True) 1abcde
12 hashed_password = Column(String) 1abcde
13 is_active = Column(Boolean, default=True) 1abcde
15 items = relationship("Item", back_populates="owner") 1abcde
18class Item(Base): 1abcde
19 __tablename__ = "items" 1abcde
21 id = Column(Integer, primary_key=True) 1abcde
22 title = Column(String, index=True) 1abcde
23 description = Column(String, index=True) 1abcde
24 owner_id = Column(Integer, ForeignKey("users.id")) 1abcde
26 owner = relationship("User", back_populates="items") 1abcde