-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodels.py
More file actions
40 lines (29 loc) · 863 Bytes
/
models.py
File metadata and controls
40 lines (29 loc) · 863 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
34
35
36
37
38
39
import sqlite3 as sql
def insertUser(email,shuttletime):
unauthorized = 0
con = sql.connect("database.db")
cur = con.cursor()
cur.execute("INSERT INTO users (Email,Shuttletime) VALUES (?,?)", (email,shuttletime))
con.commit()
con.close()
def countFunction():
con = sql.connect("database.db")
cur = con.cursor()
cur.execute("SELECT COUNT(Shuttletime), Shuttletime FROM users GROUP BY Shuttletime ORDER BY Shuttletime ASC")
count = cur.fetchall()
con.close()
return count
def retrieveID():
con = sql.connect("database.db")
cur = con.cursor()
cur.execute("SELECT id FROM users ORDER BY id DESC LIMIT 1")
id = cur.fetchone()
con.close()
return id
def retrieveUsers():
con = sql.connect("database.db")
cur = con.cursor()
cur.execute("SELECT Email, Shuttletime FROM users")
users = cur.fetchall()
con.close()
return users