Ejemplo n.º 1
0
def clear():
    connection = DBConnect()
    try:
        cursor = connection.cursor()

        queries = Query.truncate_query(Tables.USER_TABLE_NAME, Tables.USER_FOLLOW_TABLE_NAME, Tables.THREAD_TABLE_NAME,
                                       Tables.THREAD_VOTES_TABLE_NAME, Tables.THREAD_SUBSCRIBES_TABLE_NAME,
                                       Tables.POST_TABLE_NAME, Tables.POST_VOTES_TABLE_NAME, Tables.FORUM_TABLE_NAME)
        for query in queries:
            cursor.execute(query)
    except Exception as e:
        return {'code': Codes.UNKNOWN_ERROR, 'response': str(e)}
    finally:
        connection.close()

    return {'code': Codes.OK, 'response': 'OK'}
Ejemplo n.º 2
0
def status():
    connection = DBConnect()
    try:
        cursor = connection.cursor()

        result = {}
        tables = [Tables.USER_TABLE_NAME, Tables.THREAD_TABLE_NAME, Tables.FORUM_TABLE_NAME, Tables.POST_TABLE_NAME]
        for table in tables:
            query = Query.select.format(columns='count(*)', table=table)
            cursor.execute(query)
            result[table] = cursor.fetchone()[0]
    except Exception as e:
        return {'code': Codes.UNKNOWN_ERROR, 'response': str(e)}
    finally:
        connection.close()

    return {'code': Codes.OK, 'response': result}