You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
api/sql_app/models.py

38 lines
1.1 KiB
Python

from sqlalchemy import Column, Integer, Float, ForeignKey, String
from sqlalchemy.orm import relationship
from .database import Base
class Host(Base):
__tablename__ = "hosts"
id = Column(Integer, primary_key=True)
hostname = Column(String(255), unique=True, index=True)
cpus = relationship("CPU", back_populates="host")
memory = relationship("Memory", back_populates="host")
class CPU(Base):
__tablename__ = "cpus"
id = Column(Integer, primary_key=True)
socket = Column(Integer, index=True)
name = Column(String(255), index=True)
usage = Column(Float, index=True)
host_id = Column(Integer, ForeignKey("hosts.id"))
host = relationship("Host", back_populates="cpus")
class Memory(Base):
__tablename__ = "memory"
id = Column(Integer, primary_key=True)
type = Column(String(12), index=True)
total = Column(Integer, index=True)
used = Column(Integer, index=True)
usage = Column(Float, index=True)
host_id = Column(Integer, ForeignKey("hosts.id"))
host = relationship("Host", back_populates="memory")