added comments
This commit is contained in:
4
DB.py
4
DB.py
@@ -9,6 +9,7 @@ class Database:
|
||||
|
||||
|
||||
def _setup_tables(self):
|
||||
# create the shifts table.
|
||||
cur = self._con.cursor()
|
||||
cur.execute('''
|
||||
CREATE TABLE IF NOT EXISTS shifts (
|
||||
@@ -27,10 +28,12 @@ class Database:
|
||||
|
||||
|
||||
def insert_shifts(self, shifts):
|
||||
# start db connection
|
||||
cur = self._con.cursor()
|
||||
inserted = 0
|
||||
|
||||
for shift in shifts:
|
||||
# parse all information from the shift
|
||||
start = shift.get('start_datetime', 'N/A')
|
||||
end = shift.get('end_datetime', 'N/A')
|
||||
|
||||
@@ -38,6 +41,7 @@ class Database:
|
||||
duration = shift.get('duration', 'N/A')
|
||||
description = shift.get('shift_remark', shift.get('description', 'N/A'))
|
||||
|
||||
# insert it into the db.
|
||||
cur.execute("""
|
||||
INSERT OR IGNORE INTO shifts
|
||||
(shift_start, shift_end, department, duration, description)
|
||||
|
||||
Reference in New Issue
Block a user