예제 #1
0
파일: users.py 프로젝트: xang555/face_recon
def findUser(uname=None, passwd=None):
    with connect_db() as conn:
        c = conn.cursor()
        query = "SELECT * from tb_users WHERE username=? AND password=?"
        c.execute(query, (uname, hashPassword(passwd)))
        match_lists = c.fetchone()
    return match_lists
예제 #2
0
def change_profile_img(kp_id=None, profile_image=None):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = "UPDATE tb_know_people SET profile_image=? WHERE kp_id=?"
            c.execute(sql, (profile_image, kp_id))
            conn.commit()
            return True
    except DatabaseError as e:
        print(e)
        return False
예제 #3
0
def delete_know_people(kp_id=None):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = "DELETE FROM tb_know_people WHERE kp_id=?"
            c.execute(sql, (kp_id, ))
            conn.commit()
            return True
    except DatabaseError as e:
        print(e)
        return False
예제 #4
0
def update_know_people(kp_id=None, name=None, lname=None, age=None, sex=None):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = "UPDATE tb_know_people SET name=?, lname=?, age=?, sex=? WHERE kp_id=?"
            c.execute(sql, (name, lname, age, sex, kp_id))
            conn.commit()
            return True
    except DatabaseError as e:
        print(e)
        return False
예제 #5
0
def delete_camera(camera_id):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = "DELETE FROM tb_camera WHERE camera_id=?"
            c.execute(sql, (camera_id, ))
            conn.commit()
        return True
    except Error as e:
        print(e)
        return False
예제 #6
0
파일: users.py 프로젝트: xang555/face_recon
def delete_user(user_id):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            query = "DELETE FROM tb_users WHERE user_id=?"
            c.execute(query, (user_id, ))
            conn.commit()
        return True
    except DatabaseError as e:
        print(e)
        return False
예제 #7
0
파일: users.py 프로젝트: xang555/face_recon
def update_user(user_id=None, uname=None, passwd=None, level=1):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            query = "UPDATE tb_users SET username=?, password=?, level=? WHERE user_id=?"
            c.execute(query, (uname, hashPassword(passwd), level, user_id))
            conn.commit()
        return True
    except DatabaseError as e:
        print(e)
        return False
예제 #8
0
def add_know_people(name=None, lname=None, age=None, sex=None):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = "INSERT INTO tb_know_people VALUES(?, ?, ?, ?, ?, NULL)"
            kp_id = random_some_string(10)
            c.execute(sql, (kp_id, name, lname, age, sex))
            conn.commit()
            return True
    except DatabaseError as e:
        print(e)
        return False
예제 #9
0
파일: users.py 프로젝트: xang555/face_recon
def insertUser(uname=None, password=None, level=1):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            query = "INSERT INTO tb_users VALUES (?, ?, ?, ?)"
            user_id = random_some_string()
            c.execute(query, (user_id, uname, hashPassword(password), level))
            conn.commit()
        return True
    except DatabaseError as e:
        print(e)
        return False
예제 #10
0
def insert_people_access(kp_id, camera_id, full_img_path, face_img_path):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = 'INSERT INTO tb_access (kp_id, camera_id, cap_full_image_path, face_image_path, detected_time)' \
                  ' VALUES(?, ?, ?, ?, ?)'
            dt = datetime.now(timezone.utc).isoformat()
            c.execute(sql, (kp_id, camera_id, full_img_path, face_img_path, dt))
            conn.commit()
        return True
    except Error as e:
        print(e)
        return False
예제 #11
0
def add_camera(camera_code=None,
               camera_name=None,
               room_name=None,
               username=None,
               password=None,
               ip=None,
               port=554):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = "INSERT INTO tb_camera VALUES(?, ?, ?, ?, ?, ?, ?, ?)"
            camera_id = random_some_string(10)
            c.execute(sql, (camera_id, camera_code, camera_name, room_name,
                            username, password, ip, port))
            conn.commit()
        return True
    except Error as e:
        print(e)
        return False
예제 #12
0
def update_camera(camera_id=None,
                  camera_code=None,
                  camera_name=None,
                  room_name=None,
                  username=None,
                  password=None,
                  ip=None,
                  port=554):
    try:
        with connect_db() as conn:
            c = conn.cursor()
            sql = "UPDATE tb_camera set cameraCode=?, cameraName=?, roomName=?, userName=?, password=?, ip=?, port=?" \
                  "WHERE " \
                  "camera_id=? "
            c.execute(sql, (camera_code, camera_name, room_name, username,
                            password, ip, port, camera_id))
            conn.commit()
        return True
    except Error as e:
        print(e)
        return False
예제 #13
0
def list_know_people_by_id(kp_id=None):
    with connect_db() as conn:
        c = conn.cursor()
        sql = "SELECT * FROM tb_know_people WHERE kp_id=?"
        c.execute(sql, (kp_id, ))
    return c.fetchall()
예제 #14
0
def list_all_know_people():
    with connect_db() as conn:
        c = conn.cursor()
        sql = "SELECT * FROM tb_know_people"
        c.execute(sql)
    return c.fetchall()
예제 #15
0
def query_unknown_people_access(start_date, end_date):
    with connect_db() as conn:
        c = conn.cursor()
        sql = 'SELECT * FROM v_unknown_people_access WHERE detected_time >= ? AND detected_time <= ?'
        c.execute(sql, (start_date, end_date))
    return c.fetchall()
예제 #16
0
파일: users.py 프로젝트: xang555/face_recon
def find_all_users():
    with connect_db() as conn:
        c = conn.cursor()
        query = "SELECT * from tb_users"
        c.execute(query)
    return c.fetchall()