コード例 #1
0
ファイル: order.py プロジェクト: sumitjha295/ls-app
 def deleteById(self, id):
     try:
         db = DbController()
         query = "DELETE FROM tbl_orders where id = %s"
         db.execute(query, [id])
     except Exception as e:
         raise e
コード例 #2
0
ファイル: order.py プロジェクト: sumitjha295/ls-app
 def save(self):
     try:
         db = DbController()
         query = "INSERT INTO tbl_orders (id, customer_id, order_id, order_item_id, num_items, revenue, created_at_date) VALUES (NULL, %s, %s, %s, %s, %s, %s)"
         data = (self.customer_id, self.order_id, self.order_item_id,
                 self.num_items, self.revenue, self.created_at_date)
         db.execute(query, data)
         self.id = db.lastInsertedId
     except Exception as e:
         raise e
コード例 #3
0
ファイル: test_order.py プロジェクト: sumitjha295/ls-app
 def setUp(self):
     """
     Clean tbl_orders 
     """  
     db = DbController()
     query = "DELETE FROM tbl_orders"
     db.execute(query)
     """
     create object
     """      
     self.customer_id = "37d67f5feef4cb754056a54841e43ad9"
     self.order_id = 4662083 
     self.order_item_id = 21257304
     self.num_items = 1
     self.revenue = 24.79
     self.created_at_date = "2017-09-01"
     self.orderObject = Order(self.customer_id,self.order_id,self.order_item_id,self.num_items,self.revenue,self.created_at_date)
コード例 #4
0
 def test_execute(self):
     """
     Test db execute
     """
     dbObject = DbController()
     cfg = dbConfig()
     query = 'SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = %s'
     value = dbObject.execute(query, [cfg["db"]])
     self.assertEqual(dbObject.rowCount, 1)