class Orden_canje(config.Base): __tablename__ = 'orden_canje' n_orden = config.Column(config.Integer, primary_key=True, nullable=False) total = config.Column(config.Integer) user_id = config.Column(config.Integer, config.ForeignKey('user.user_id'), nullable=False) model.user = config.relationship('model.user.User')
class Orden_producto(config.Base): __tablename__ = 'orden_producto' n_orden = config.Column(config.Integer, config.ForeignKey('orden_canje.n_orden'), primary_key = True, nullable = False) #n_orden_producto = config.Column(config.Integer, primary_key = True, nullable = False) id_producto = config.Column(config.Integer, config.ForeignKey('producto.id_producto'), primary_key = True, nullable = False) cantidad = config.Column(config.Integer) model.orden_canje = config.relationship('model.orden_canje.Orden_canje') model.producto = config.relationship('model.producto.Producto')
class Credencial(config.Base): __tablename__ = 'credencial' user_name = config.Column(config.String(50), primary_key=True, nullable=False) password = config.Column(config.String(50)) user_id = config.Column(config.Integer, config.ForeignKey('user.user_id'), nullable=False) model.user = config.relationship('model.user.User')
class Producto(config.Base): __tablename__ = 'producto' id_producto = config.Column(config.Integer, primary_key=True, nullable=False) descripcion = config.Column(config.String(50)) valor = config.Column(config.Integer) def productos_to_dict(self): return { col.name: getattr(self, col.name) for col in self.__table__.columns } def save(self): config.save_to_db(self) def listar_productos(self): prod = config.select(producto) result = config.execute(prod)
class User(config.Base, UsersToDict): __tablename__ = 'user' user_id = config.Column(config.Integer, primary_key=True, nullable=False) first_name = config.Column(config.String(50)) last_name = config.Column(config.String(50)) puntaje = config.Column(config.Integer)