Exemplo n.º 1
0
 def get_by_sku(self, sku):
     p = self.c.execute('SELECT * FROM products WHERE sku=?', (sku, ))
     try:
         return ProductModel.fromDB(p.fetchall()[0])
     except IndexError:
         return False
Exemplo n.º 2
0
 def list(self):
     p = self.c.execute('SELECT * FROM products')
     try:
         return [ProductModel.fromDB(product) for product in p.fetchall()]
     except Exception as e:
         raise e
Exemplo n.º 3
0
 def search(self, **kwargs):
     query = 'SELECT * FROM products WHERE (' + self.build_query(
         kwargs) + ')'
     print(query)
     results = self.c.execute(query)
     return [ProductModel.fromDB(r) for r in results.fetchall()]