| from sqlalchemy import Column, Integer, DECIMAL, TIMESTAMP, text |
| from sqlalchemy.ext.declarative import declarative_base |
| from sqlalchemy.sql import func |
| |
| Base = declarative_base() |
| |
| class GpuUsage(Base): |
| __tablename__ = 'gpu_usage' |
| __table_args__ = { |
| 'mysql_engine': 'InnoDB', |
| 'mysql_charset': 'utf8mb4', |
| 'comment': 'GPU 使用情况表' |
| } |
| |
| gpu_id = Column(Integer, primary_key=True, nullable=False, comment='GPU 编号') |
| gpu_usage = Column(DECIMAL(5, 2), nullable=False, comment='GPU 使用率,单位:百分比') |
| gpu_memory_usage = Column(Integer, nullable=False, comment='GPU 内存用量,单位:MB') |
| created_at = Column(TIMESTAMP, nullable=False, server_default=text('CURRENT_TIMESTAMP'), comment='记录时间戳') |