コード例 #1
0
def delete_eq(name):
    db = get_db()
    cursor = db.cursor()
    statement = "DELETE FROM EQUIPMENTS WHERE NAME =  ?"
    cursor.execute(statement, [name])
    db.commit()
    return True
コード例 #2
0
def update_eq_manager(id, status, request):
    db = get_db()
    cursor = db.cursor()
    statement = "UPDATE EQUIPMENTS SET STATUS = ?, REQUEST = ? WHERE ID = ?"
    cursor.execute(statement, [status, request, id])
    db.commit()
    return True
コード例 #3
0
def insert_eq(name, status, request):
    db = get_db()
    cursor = db.cursor()
    statement = "INSERT INTO EQUIPMENTS(NAME, STATUS, REQUEST) VALUES (?, ?, ?)"
    cursor.execute(statement, [name, status, request])
    db.commit()
    return True
コード例 #4
0
def search_manager(name):
    db = get_db()
    cursor = db.cursor()
    like = f'%{name}%'
    statement = "SELECT * FROM EQUIPMENTS WHERE NAME LIKE ? "
    cursor.execute(statement, [like]) 
    return cursor.fetchall()
コード例 #5
0
def search_student(name):
    db = get_db()
    cursor = db.cursor()
    like = f'%{name}%'
    statement = "SELECT ID, NAME FROM EQUIPMENTS WHERE NAME LIKE ? AND REQUEST IS NULL"
    cursor.execute(statement, [like]) 
    return cursor.fetchall()
コード例 #6
0
def update_eq_student(id, status, request):
    db = get_db()
    cursor = db.cursor()
    statement = "UPDATE EQUIPMENTS SET STATUS = ?, REQUEST = ? WHERE ID = ?"
    cursor.execute(statement, [status, request, id])
    db.commit()
    if request == None:
        return "Equipment Returned" 
    return "Equipment Requested"
コード例 #7
0
def get_eq_manager_req():
    db = get_db()
    cursor = db.cursor()
    query = "SELECT ID, NAME, STATUS, REQUEST FROM EQUIPMENTS WHERE REQUEST IS NOT NULL"
    cursor.execute(query)
    return cursor.fetchall()
コード例 #8
0
def get_eq_student():
    db = get_db()
    cursor = db.cursor()
    query = "SELECT ID, NAME FROM EQUIPMENTS WHERE REQUEST IS NULL"
    cursor.execute(query)
    return cursor.fetchall()
コード例 #9
0
def get_by_id(id):
    db = get_db()
    cursor = db.cursor()
    statement = "SELECT * FROM EQUIPMENTS WHERE ID = ?"
    cursor.execute(statement, [id])
    return cursor.fetchone()