app.backbone.entities.category
1from sqlalchemy import Column, Integer, String, Float 2from sqlalchemy.orm import relationship 3 4from . import Base 5 6# Clase que representa una tabla en la base de datos 7class Category(Base): 8 __tablename__ = 'Categories' # Cambié el nombre para evitar colisión con Tickers 9 10 Id = Column(Integer, primary_key=True, autoincrement=True) 11 Name = Column(String, nullable=False) 12 Commission = Column(Float, nullable=False) 13 14 Tickers = relationship('Ticker', back_populates='Category', lazy='joined') 15 16 def __repr__(self): 17 return f"<Category(id={self.Id}, name='{self.Name}')>"
class
Category(sqlalchemy.orm.decl_api._DynamicAttributesType, sqlalchemy.inspection.Inspectable[sqlalchemy.orm.mapper.Mapper[typing.Any]]):
8class Category(Base): 9 __tablename__ = 'Categories' # Cambié el nombre para evitar colisión con Tickers 10 11 Id = Column(Integer, primary_key=True, autoincrement=True) 12 Name = Column(String, nullable=False) 13 Commission = Column(Float, nullable=False) 14 15 Tickers = relationship('Ticker', back_populates='Category', lazy='joined') 16 17 def __repr__(self): 18 return f"<Category(id={self.Id}, name='{self.Name}')>"
The base class of the class hierarchy.
When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.
Category(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and
values in kwargs.
Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.