-
Notifications
You must be signed in to change notification settings - Fork 0
/
price.py
31 lines (22 loc) · 915 Bytes
/
price.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class price:
def __init__(self, db_cursor, mydb):
self.db_cursor = db_cursor
self.mydb = mydb
def add_price(self, price_value):
sql = "INSERT INTO price (price_value) VALUES (%s)"
val = (price_value, )
self.db_cursor.execute(sql, val)
self.mydb.commit()
print(self.db_cursor.rowcount, "record inserted.")
def update_price(self, price_id, price_value):
sql = "UPDATE price SET price_value = %s WHERE price_id = %s"
val = (price_value, price_id)
self.db_cursor.execute(sql, val)
self.mydb.commit()
print(self.db_cursor.rowcount, "record updated.")
def delete_price(self, price_id):
sql = "DELETE FROM price WHERE price_id = %s"
val = (price_id, )
self.db_cursor.execute(sql, val)
self.mydb.commit()
print(self.db_cursor.rowcount, "record deleted.")