Exemple #1
0
    def get_registration_info(registration_id):
        with get_hpz_connection() as conn:
            file_reg_table = conn.get_table(table_name=HPZ.TABLE_NAME)
            result = conn.execute(file_reg_table.select().where(file_reg_table.c.registration_id == registration_id))

            registration_info = result.fetchone()

            return registration_info
Exemple #2
0
    def register_request(user_id, email):
        registration_id = uuid4()
        registration_info = {HPZ.REGISTRATION_ID: str(registration_id), HPZ.USER_ID: user_id, HPZ.EMAIL: email}

        with get_hpz_connection() as conn:
            file_reg_table = conn.get_table(table_name=HPZ.TABLE_NAME)
            conn.execute(file_reg_table.insert().values(registration_info))

        return registration_id
Exemple #3
0
    def update_registration(registration_id, file_path, file_name):
        registration_info = {HPZ.FILE_PATH: file_path,
                             HPZ.CREATE_DT: datetime.now(),
                             HPZ.FILE_NAME: file_name}

        with get_hpz_connection() as conn:
            file_reg_table = conn.get_table(table_name=HPZ.TABLE_NAME)
            result = conn.execute(file_reg_table.update().where(file_reg_table.c.registration_id == registration_id).
                                  values(registration_info))

            return result.rowcount > 0
def check_database():
    '''
    check database connection
    '''
    database_ok = False
    try:
        with get_hpz_connection() as conn:
            query = select([1])
            results = conn.get_result(query)
            if len(results) > 0:
                database_ok = True
    except Exception as e:
        logger.error('HPZ Heartbeat failed. Check DB connection.' + str(e))
        pass
    return database_ok
Exemple #5
0
def check_database():
    '''
    check database connection
    '''
    database_ok = False
    try:
        with get_hpz_connection() as conn:
            query = select([1])
            results = conn.get_result(query)
            if len(results) > 0:
                database_ok = True
    except Exception as e:
        logger.error('HPZ Heartbeat failed. Check DB connection.' + str(e))
        pass
    return database_ok
Exemple #6
0
    def is_file_registered(registration_id):
        with get_hpz_connection() as conn:
            file_reg_table = conn.get_table(table_name=HPZ.TABLE_NAME)
            result = conn.execute(file_reg_table.select(limit=1).where(file_reg_table.c.registration_id == registration_id))

            return result.rowcount == 1