Exemple #1
0
def insert_point(**kwargs):
    session = SESSION()
    try:
        roll = RollHistory(**kwargs)
        session.add(roll)
        session.commit()
    except Exception as e:
        return e
    finally:
        session.close()
Exemple #2
0
def insert_lang_ref(**kwargs):
    session = SESSION()
    try:
        lang = session.query(PythonLangRef).filter_by(
            title1=kwargs.get('title1'), title2=kwargs.get('title2')).first()
        if lang:
            lang.update(**kwargs)
        else:
            lang = PythonLangRef(**kwargs)
            session.add(lang)
        session.commit()
    except Exception as e:
        pass
    finally:
        session.close()
def insert_new_captcha(**kwargs):
    '''

    :param kwargs: group_id, user_id, verify_code
    :return:
    '''
    nmc = NewMemberCaptcha(**kwargs)
    session = SESSION()
    try:
        session.add(nmc)
        session.commit()
    except Exception as e:
        pass
    finally:
        session.close()
Exemple #4
0
def insert_lib(**kwargs):
    session = SESSION()
    try:
        lib = session.query(PythonLibs).filter_by(
            name=kwargs.get('lib_name')).first()
        if lib:
            lib.update(**kwargs)

        else:
            lib = PythonLibs(**kwargs)
            session.add(lib)
        session.commit()
    except Exception as e:
        pass
    finally:
        session.close()
Exemple #5
0
def to_zero(user_id):
    session = SESSION()
    try:
        d = session.query(Days).filter_by(user_id=user_id).first()
        if not d:
            d = Days(user_id=user_id, days=0)
            session.add(d)
            session.commit()
            return
        d.days = 0
        session.commit()
        return True
    except Exception as e:
        session.rollback()
    finally:
        session.close()
 def add(self):
     SESSION.add(self)
     SESSION.commit()