예제 #1
0
def clear(request):
    cursor = connection.cursor()
    
    for table in ['post_hierarchy_utils', 'followers', 'subscriptions',
                  'post', 'thread', 'forum', 'user']:
        cursor.execute(CLEAR_TABLE.format(table))
        cursor.execute(SET_AUTO_INCREMENT_BY_ZERO.format(table))
    result = {"code": codes.OK, "response": "OK"}
    cursor.close()
    return HttpResponse(dumps(result))
예제 #2
0
파일: clear.py 프로젝트: niggor/apiDB
def clear(request):
    cursor = connection.cursor()
    set_fk='''SET FOREIGN_KEY_CHECKS = 0;'''
    cursor.execute(set_fk)
    for table in ['post_hierarchy_utils', 'followers', 'subscriptions',
                  'post', 'thread','user_to_forum', 'forum', 'user']:
        cursor.execute(CLEAR_TABLE.format(table))
        cursor.execute(RESET_AUTO_INCREMENT.format(table))
    result = {"code": codes.OK,
              "response": "OK"
             }
    set_fk_1 ='''SET FOREIGN_KEY_CHECKS = 1;'''
    cursor.execute(set_fk_1)
    cursor.close()
    return HttpResponse(dumps(result))