-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.py
47 lines (40 loc) · 1.41 KB
/
backend.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
import sqlite3
def connect():
conn=sqlite3.connect("data.db")
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS datas (id INTEGER PRIMARY KEY,email text, pass text, types text,notes text,timenow text)")
conn.commit()
conn.close()
def insert(email,pas,types,notes,timenow):
conn = sqlite3.connect("data.db")
cur = conn.cursor()
cur.execute("INSERT INTO datas VALUES (NULL,?,?,?,?,?)",(email,pas,types,notes,timenow))
conn.commit()
conn.close()
def View():
conn = sqlite3.connect("data.db")
cur = conn.cursor()
cur.execute("SELECT * FROM datas")
rows=cur.fetchall()
conn.close()
return rows
def search(email="",pas="",types="",notes="",timenow=""):
conn = sqlite3.connect("data.db")
cur = conn.cursor()
cur.execute("SELECT * FROM datas WHERE email=? OR pas=? OR types=? OR notes=?",(email ,pas , types , notes , timenow))
rows = cur.fetchall()
conn.close()
return rows
def deleteitem(id):
conn = sqlite3.connect("data.db")
cur = conn.cursor()
cur.execute("DELETE FROM datas WHERE id=?",(id,))
conn.commit()
conn.close()
def update(id,email,pas,types,notes,):
conn = sqlite3.connect("data.db")
cur = conn.cursor()
cur.execute("UPDATE datas SET email=?, pas=?, types=?, notes=? WHERE id=?",(email,pas,types,notes,id))
conn.commit()
conn.close()
connect()#automatically gets called when frontend file executed