-
Notifications
You must be signed in to change notification settings - Fork 0
/
d_class.py
51 lines (46 loc) · 1.45 KB
/
d_class.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from connection import *
class db_class(Connection):
def __init__(self):
super().__init__()
def select(self):
try:
cur = self.conn().cursor()
cur.execute("SELECT * FROM sem")
return cur.fetchall()
except sqlite3.Error as err:
print(f"{err}")
finally:
self.con.close()
def add(self,*args):
try:
con = self.conn()
cur = con.cursor()
cur.execute("INSERT INTO sem(name, amount, price) VALUES(?,?,?)",args)
con.commit()
return "product has been sucesfully added"
except sqlite3.Error as err:
print(f"{err}")
finally:
self.con.close()
def update(self,*args):
try:
con = self.conn()
cur = con.cursor()
cur.execute("UPDATE sem SET name = ?, amount = ?, price = ? WHERE id = ?",args)
con.commit()
return "product has been succesfully edited"
except sqlite3.Error as err:
print(f"{err}")
finally:
self.con.close()
def delete(self,*args):
try:
con = self.conn()
cur = con.cursor()
cur.execute("DELETE FROM sem WHERE id = ?",args)
con.commit()
return "product has been deleted"
except sqlite3.Error as err:
print(f"{err}")
finally:
self.con.close()