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))
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))