TRM-coding | 106204b | 2025-06-28 00:37:46 +0800 | [diff] [blame^] | 1 | from sqlalchemy import Column, Integer, DECIMAL, TIMESTAMP, text |
| 2 | from sqlalchemy.ext.declarative import declarative_base |
| 3 | from sqlalchemy.sql import func |
| 4 | |
| 5 | Base = declarative_base() |
| 6 | |
| 7 | class GpuUsage(Base): |
| 8 | __tablename__ = 'gpu_usage' |
| 9 | __table_args__ = { |
| 10 | 'mysql_engine': 'InnoDB', |
| 11 | 'mysql_charset': 'utf8mb4', |
| 12 | 'comment': 'GPU 使用情况表' |
| 13 | } |
| 14 | |
| 15 | gpu_id = Column(Integer, primary_key=True, nullable=False, comment='GPU 编号') |
| 16 | gpu_usage = Column(DECIMAL(5, 2), nullable=False, comment='GPU 使用率,单位:百分比') |
| 17 | gpu_memory_usage = Column(Integer, nullable=False, comment='GPU 内存用量,单位:MB') |
| 18 | created_at = Column(TIMESTAMP, nullable=False, server_default=text('CURRENT_TIMESTAMP'), comment='记录时间戳') |