from datetime import datetime from sqlalchemy import Column, Integer, Float, Boolean, DateTime, BigInteger from .device import Base class PingRecord(Base): """单次 ping 结果记录""" __tablename__ = "ping_records" id = Column(BigInteger, primary_key=True, autoincrement=True) device_id = Column(Integer, nullable=False, index=True) is_alive = Column(Boolean, nullable=False, comment="是否通") response_time_ms = Column(Float, nullable=True, comment="响应时间毫秒,不通则为 NULL") round_num = Column(Integer, nullable=False, comment="轮次编号(从 1 递增)") created_at = Column(DateTime, default=datetime.now, index=True, comment="记录时间") def __repr__(self): return f""