-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrud.py.save
41 lines (30 loc) · 909 Bytes
/
Crud.py.save
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
from Connection import Connection
class Crud:
def insert(self, text):
conn = Connection().conn()
cursor = conn.cursor()
sql = "INSERT INTO tess "
cursor.execute(sql, (text, ))
conn.commit()
lastid = cursor.lastrowid
cursor.close()
conn.close()
return lastid
def getAll(self):
conn = Connection().conn()
cursor = conn.cursor()
cursor.execute("SELECT * FROM tess")
result = cursor.fetchall()
cursor.close()
conn.close()
return result
def find(self, id):
conn = Connection().conn()
cursor = conn.cursor()
sql = "Select * FROM tess WHERE id = {id}".format(id = id)
print(sql)
cursor.execute(sql)
result = cursor.fetchall()
cursor.close()
conn.close()
return result