R
R
RaymanPy2019-02-07 13:26:33
SQL
RaymanPy, 2019-02-07 13:26:33

SQLALCHEMY filter?

models.py

class Catalog(Base):
  __tablename__ = 'catalog'

  id = Column(Integer, primary_key=True)
  name = Column(String(100))
  price = Column(String(100))
  color = Column(String(100))
  memory = Column(String(100))
  
  country = Column(String(100))
  sim = Column(String(100))
  type = Column(String(100))
  code = Column(String(100))
  

  def __init__(self, name,price,color,memory,country,type,code,sim=1):
    self.name = name
    self.price = price
    self.color = color
    self.memory = memory
    self.country = country
    self.code = code
    self.sim = sim
    self.type = type

  def __repr__(self):
    return '< Catalog id: {}, name: {} >'.format(self.id, self.name)

How to filter a table by multiple parameters:
To get the values ​​with name == 'XXX', and name =='YYY' combined

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RaymanPy, 2019-02-07
@RaymanPy

Karoch, you need to use the function or_()
here is an example:

catalog = session.query(Catalog).filter(or_(Catalog.name=='blalala',Catalog.name=='AYAYAY')).all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question