def get_device_id(): exitdeviceForm.dev_id = run() query1 = "update belongs set status = ?, current_lab = ? where device_id = ?" cursor.execute(query1, ("out", None, exitdeviceForm.dev_id)) query = "INSERT INTO log VALUES (?, ?, ?, ?)" cursor.execute(query, (exitdeviceForm.dev_id, None, "out", datetime.now())) con.commit() view(master)
def exita(): id1 = run() # res = get_lab(id1) # print(res[0]) query1 = "update belongs set status = ?, current_lab = ? where device_id = ?" cursor.execute(query1, ("out", None, id1)) query = "INSERT INTO log VALUES (?, ?, ?, ?)" cursor.execute(query, (id1, None, "out", datetime.now())) db.commit() test_run()
def enter(): flag = None id1 = run() res = get_lab(id1) query1 = "update belongs set status = ?, current_lab = ? where device_id = ?" if res[0] == lab_id: flag = "in" else: flag = "out" cursor.execute(query1, (flag, lab_id, id1)) query = "INSERT INTO log VALUES (?, ?, ?, ?)" cursor.execute(query, (id1, lab_id, "in", datetime.now())) db.commit() test_run()
def enterdevice(): enterdeviceForm.dev_id = run() print(enterdeviceForm.dev_id) flag = None res = lab_no_en.get() query1 = "update belongs set status = ?, current_lab = ? where device_id = ?" query_lab_id = "select lab_id from belongs where device_id = ?" lab_id = cursor.execute(query_lab_id, (enterdeviceForm.dev_id, )) res = lab_no_en.get() if res == lab_id: flag = "in" else: flag = "out" print(flag) cursor.execute(query1, (flag, res, enterdeviceForm.dev_id)) query = "INSERT INTO log VALUES (?, ?, ?, ?)" cursor.execute(query, (enterdeviceForm.dev_id, res, "in", datetime.now())) con.commit() view(master)
import sqlite3 from ardRfid import run from datetime import datetime db = sqlite3.connect('data.db') cursor = db.cursor() query = "CREATE TABLE devices(device_id TEXT PRIMARY KEY, description TEXT)" cursor.execute(query) query = "INSERT INTO devices VALUES(?, ?)" print('ENTER DEVICE FOR LAB 1') id1 = run() cursor.execute(query, (id1, "printer lab 1")) print('PRINTER WITH ', id1, 'ENTERED IN LAB 1 ') print('ENTER DEVICE FOR LAB 2') id2 = run() cursor.execute(query, (id2, "printer lab 2")) print('PRINTER WITH ', id2, 'ENTERED IN LAB 2 ') query = "CREATE TABLE labs(lab_id INTEGER PRIMARY KEY, description TEXT)" cursor.execute(query) query = "INSERT INTO labs VALUES(?, ?)" cursor.execute(query, (1, "1st floor lab")) cursor.execute(query, (2, "2nd floor lab")) query = "CREATE TABLE belongs(lab_id INTEGER, device_id TEXT, status TEXT, current_lab INTEGER)" cursor.execute(query) query = "INSERT INTO belongs VALUES (?, ?, ?, ?)" cursor.execute(query, (1, id1, "in", 1))
def registerdevice(): adddeviceForm.dev_id = run() print(adddeviceForm.dev_id)