update for punch out works
This commit is contained in:
18
database.py
18
database.py
@@ -10,16 +10,6 @@ cur = con.cursor()
|
||||
cur.execute("CREATE TABLE IF NOT EXISTS TIMESTAMPS (session_id INTEGER PRIMARY KEY, time_in STRING, time_out STRING, name STRING, purpose STRING);")
|
||||
cur.execute("CREATE TABLE IF NOT EXISTS USERS (id INTEGER PRIMARY KEY, name STRING, cumulative_hours INTEGER);")
|
||||
|
||||
# declare and insert some initial values
|
||||
timestamp_list = [
|
||||
('Mikayla', 'work on project'),
|
||||
('not Mikayla', 'work on project'),
|
||||
('someone else', 'debugging')
|
||||
]
|
||||
|
||||
cur.executemany("INSERT INTO TIMESTAMPS (name, purpose) VALUES (?, ?)", timestamp_list)
|
||||
con.commit()
|
||||
|
||||
# Functions to define:
|
||||
# 1) Select all timestamps
|
||||
# 2) Find a timestamp by date range
|
||||
@@ -31,6 +21,14 @@ def create_new_stamp(timestamp, name, purpose):
|
||||
cur.execute("INSERT INTO TIMESTAMPS (time_in, name, purpose) VALUES (?, ?, ?)", to_insert)
|
||||
con.commit()
|
||||
|
||||
def punch_out(timestamp, id):
|
||||
data = (timestamp, id)
|
||||
cur.execute("""UPDATE TIMESTAMPS
|
||||
SET time_out = ?
|
||||
WHERE session_id = ?
|
||||
""", data)
|
||||
con.commit()
|
||||
|
||||
def get_all_stamps():
|
||||
return cur.execute("SELECT * FROM TIMESTAMPS;")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user