def db_delete_application(language_id):
    session = DBSession()
    delete_data = session.query(Application).filter(Application.id == language_id). \
        delete(synchronize_session=False)
    session.commit()
    session.close()
    return 1
def db_delete_language(language_id):
    session = DBSession()
    delete_data = session.query(Language).filter(Language.id == language_id). \
        delete(synchronize_session=False)
    session.commit()
    session.close()
    return 1
def db_get_application_page(page_size,page):
    session = DBSession()
    count = session.query(Application).count()
    query = session.query(Application).limit(page_size).offset((int(page)-1)* int(page_size))
    session.commit()
    session.close()
    return query,count
def db_delete_character(character_id):
    session = DBSession()
    delete_data = session.query(Character).filter(Character.id == character_id). \
        delete(synchronize_session=False)
    session.commit()
    session.close()
    return 1
def db_get_character_page(page_size,page):
    session = DBSession()
    count = session.query(Character).count()
    query = session.query(Character).limit(page_size).offset((int(page)-1) * int(page_size))
    session.commit()
    session.close()
    return query,count
Esempio n. 6
0
def db_delete_translation_character_id(character_id):
    session = DBSession()
    delete_data = session.query(Translation).filter(Translation.character_id == character_id). \
        delete(synchronize_session=False)
    session.commit()
    session.close()
    return 1
Esempio n. 7
0
def db_delete_translation(language_id, application_id, character_id):
    session = DBSession()
    delete_data = session.query(Translation).filter(Translation.language_id == language_id, \
                                                  Translation.application_id == application_id ,\
                                                    Translation.character_id == character_id). \
        delete(synchronize_session=False)
    session.commit()
    session.close()
    return 1
def db_get_application_id(application_id):
    session = DBSession()
    language_list = session.query(Application).filter(Application.id == application_id).first()
    if language_list:
        respon_dict = tool.language2dict(language_list)
    else:
        respon_dict = {}
    session.commit()
    session.close()
    return respon_dict
def db_get_id_character(name):
    session = DBSession()
    post_flag = session.query(Character).filter(Character.name == name).first()
    if post_flag:
        respon_dict = tool.language2dict(post_flag)
    else:
        respon_dict = 0
    session.commit()
    session.close()
    return respon_dict
Esempio n. 10
0
def db_get_character_id(character_id):
    session = DBSession()
    character_list = session.query(Character).filter(Character.id == character_id).first()
    if character_list:
        respon_dict = tool.language2dict(character_list)
    else:
        respon_dict = {}
    session.commit()
    session.close()
    return respon_dict
Esempio n. 11
0
def db_get_translation_id(translation_id):
    session = DBSession()
    translation_list = session.query(Translation).filter(
        Translation.id == translation_id).first()
    if translation_list:
        respon_dict = tool.translation2dict(translation_list)
    else:
        respon_dict = []
    session.commit()
    session.close()
    return respon_dict
Esempio n. 12
0
def db_get_id_language(accept_language):
    session = DBSession()
    language_list = session.query(Language).filter(
        Language.name == accept_language).first()
    if language_list:
        respon_dict = tool.language2dict(language_list)
    else:
        respon_dict = {}
    session.commit()
    session.close()
    return respon_dict
Esempio n. 13
0
def db_get_id_translation(language_id, application_id, character_id):
    session = DBSession()
    post_flag = session.query(Translation).filter(Translation.language_id == language_id, \
                                                  Translation.application_id == application_id ,\
                                                    Translation.character_id == character_id).first()
    if post_flag:
        respon_dict = tool.translation2dict(post_flag)
    else:
        respon_dict = 0
    session.commit()
    session.close()
    return respon_dict
Esempio n. 14
0
def db_get_character_list():
    session = DBSession()
    character_list = session.query(Character).all()
    respon_dict = []
    if character_list:
        for i in character_list:
            json_transform = tool.language2dict(i)
            respon_dict.append(json_transform)
    else:
        respon_dict = []
    session.commit()
    session.close()
    return respon_dict
Esempio n. 15
0
def db_get_language_list():
    session = DBSession()
    language_list = session.query(Language).all()
    respon_dict = []
    if language_list:
        for i in language_list:
            json_transform = tool.language2dict(i)
            respon_dict.append(json_transform)
    else:
        respon_dict = []
    session.commit()
    session.close()
    return respon_dict
Esempio n. 16
0
def db_get_translation_list():
    session = DBSession()
    translation_list = session.query(Translation).all()
    respon_dict = []
    if translation_list:
        for i in translation_list:
            json_transform = tool.translation2dict(i)
            respon_dict.append(json_transform)
    else:
        respon_dict = []
    session.commit()
    session.close()
    return respon_dict
Esempio n. 17
0
def db_get_language_translation(language_id, application_id):
    session = DBSession()
    translation_list = session.query(Translation).filter(\
        Translation.language_id == language_id,Translation.application_id == application_id).all()
    respon_dict = {}
    if translation_list:
        for i in translation_list:
            respon_dict[i.character.name] = i.cha_translation
    else:
        respon_dict = {}
    session.commit()
    session.close()
    return respon_dict
Esempio n. 18
0
def db_get_translation_cha_id_app_id(character_id, application_id):
    session = DBSession()
    translation_list = session.query(Translation).filter(\
        Translation.character_id == character_id,Translation.application_id == application_id).order_by(Translation.language_id).all()
    respon_dict = []
    if translation_list:
        for i in translation_list:
            json_transform = tool.lan(i)
            respon_dict.append(json_transform)
    else:
        respon_dict = []
    session.commit()
    session.close()
    return respon_dict
Esempio n. 19
0
def db_get_translation_group(page_size, page, app_id):
    session = DBSession()
    if app_id == 0:
        count = session.query(Translation.character_id,Translation.application_id).\
            order_by(Translation.character_id,Translation.application_id).\
            group_by(Translation.character_id,Translation.application_id).count()
        #query = session.query(Translation).order_by(Translation.application_id).limit(page_size).offset((int(page)-1) * int(page_size))
        query = session.query(Translation.character_id,Translation.application_id).\
            order_by(Translation.character_id,Translation.application_id).\
            group_by(Translation.character_id,Translation.application_id).limit(page_size).offset((int(page)-1) * int(page_size)).all()
    else:
        count = session.query(Translation.character_id, Translation.application_id).filter(Translation.application_id == app_id).\
            order_by(Translation.character_id, Translation.application_id). \
            group_by(Translation.character_id, Translation.application_id).count()
        # query = session.query(Translation).order_by(Translation.application_id).limit(page_size).offset((int(page)-1) * int(page_size))
        query = session.query(Translation.character_id, Translation.application_id). filter(Translation.application_id == app_id).\
            order_by(Translation.character_id, Translation.application_id). \
            group_by(Translation.character_id, Translation.application_id).limit(page_size).offset(
            (int(page) - 1) * int(page_size)).all()
    session.commit()
    session.close()
    return query, count