-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.py
More file actions
33 lines (28 loc) · 801 Bytes
/
database.py
File metadata and controls
33 lines (28 loc) · 801 Bytes
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
import sqlite3
def connect():
conn=sqlite3.connect("database.db")
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS history (id INTEGER PRIMARY KEY, email text, date text)")
conn.commit()
conn.close()
def insert(email,date):
conn=sqlite3.connect("database.db")
cur=conn.cursor()
cur.execute("INSERT INTO history VALUES (NULL,?,?)",(email,date))
conn.commit()
conn.close()
view()
def view():
conn=sqlite3.connect("database.db")
cur=conn.cursor()
cur.execute("SELECT * FROM history")
rows=cur.fetchall()
conn.close()
return rows
def delete():
conn=sqlite3.connect("database.db")
cur=conn.cursor()
cur.execute("DELETE FROM history")
conn.commit()
conn.close()
connect()