-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.py
executable file
·39 lines (34 loc) · 1.1 KB
/
database.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
from sqlite3 import connect
class Database:
@staticmethod
def insert(code,name, family,birthdate, image):
try:
con = connect("Employee.db")
cr = con.cursor()
cr.execute(f"INSERT INTO Employee(CodeMelli,Name,Family,BirthDate,Image)VALUES('{code}','{name}','{family}','{birthdate}','{image}')")
con.commit()
con.close()
return True
except:
return False
@staticmethod
def edit(i,code,n, f,b, img):
# try:
con = connect("Employee.db")
cr = con.cursor()
cr.execute(f"UPDATE Employee SET CodeMelli='{code}' ,Name='{n}', Family='{f}',BirthDate='{b}',Image='{img}' WHERE Id='{i}'")
con.commit()
con.close()
return True
# except:
# return False
@staticmethod
def select():
try:
con=connect("Employee.db")
cr=con.cursor()
cr.execute("SELECT * FROM Employee")
res=cr.fetchall()
return res
except:
return []