當前位置: 首頁>>代碼示例>>Python>>正文


Python dbSession.DBSession類代碼示例

本文整理匯總了Python中db.dbSession.DBSession的典型用法代碼示例。如果您正苦於以下問題:Python DBSession類的具體用法?Python DBSession怎麽用?Python DBSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DBSession類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: queryByUserId

    def queryByUserId(cls, userid):
        session = DBSession()
        u = session.query(cls).filter(cls.id==userid).first()
        if not u:
            return None
        else:
            return u
開發者ID:euzhang,項目名稱:auto,代碼行數:7,代碼來源:account_models.py

示例2: queryByAnswerId

    def queryByAnswerId(cls, answerId, voteValue):
        session = DBSession()
        name = session.query(AutoUser.name).filter(AutoUser.id == AnswerVote.vote_uid, AnswerVote.answer_id == answerId, AnswerVote.vote_value == voteValue).distinct().all()
        namelist = []
        for str in name :
            namelist.append(str[0])
        return namelist
開發者ID:euzhang,項目名稱:auto,代碼行數:7,代碼來源:answer_vote_models.py

示例3: queryByUsername

    def queryByUsername(cls, username):
        """ 按用戶名查詢用戶 """
        session = DBSession()
        u = session.query(cls).filter(cls.user_name==username).first()
        if not u:
            return None
        else:
            return u
開發者ID:hellowego,項目名稱:auto,代碼行數:8,代碼來源:users_models.py

示例4: queryByUserIdAndLinkId

    def queryByUserIdAndLinkId(cls, userId, linkid):
        session = DBSession()
        userVote = session.query(cls).filter(cls.user_id == userId, cls.link_id == linkid).first()
        session.close()
        if not userVote:
            return False
        else:
            print userVote
            return userVote
開發者ID:hellowego,項目名稱:auto,代碼行數:9,代碼來源:user_vote_model.py

示例5: checkUsername

    def checkUsername(cls, username):
        '''
        檢查用戶名是否已經被注冊
        '''
        session = DBSession()
        u = session.query(cls).filter(cls.name==username).first()

        if not u:
            return False
        else:
            return u

        print 'hi'
開發者ID:euzhang,項目名稱:auto,代碼行數:13,代碼來源:account_models.py

示例6: checkEmail

    def checkEmail(cls, email):
        '''
        檢查郵箱是否已經被注冊
        '''
        session = DBSession()
        u = session.query(cls).filter(cls.email==email).first()

        if not u:
            return False
        else:
            return u

        print 'hi'
開發者ID:euzhang,項目名稱:auto,代碼行數:13,代碼來源:account_models.py

示例7: queryUser

    def queryUser(cls, username, password):
        # 創建session對象:
        session = DBSession()
        u = session.query(cls).filter(cls.name==username).first()

        if not u:
            return False

        hashed_password = bcrypt.hashpw(password, tornado.escape.utf8(u.hashed_password))

        if u.hashed_password == hashed_password:
            return u
        else:
            print 'wrong  password'
            return False
開發者ID:euzhang,項目名稱:auto,代碼行數:15,代碼來源:account_models.py

示例8: addAnswerComment

    def addAnswerComment(cls, answer_id, uid, message):
        obj = cls(answer_id = answer_id, uid = uid, message = message)
        session = DBSession()
        session.add(obj)
        session.commit()
        session.close()
        return True
開發者ID:euzhang,項目名稱:auto,代碼行數:7,代碼來源:answerComment_models.py

示例9: add

    def add(cls, userid, linkid, type):
        obj = cls(user_id = userid, link_id = linkid, type = type, add_time = long(time.time()))
        session = DBSession()
        session.add(obj)
        session.commit()
        session.close()
        return True
開發者ID:hellowego,項目名稱:auto,代碼行數:7,代碼來源:user_vote_model.py

示例10: add

    def add(cls, session_id, value):
        obj = cls(session_id = session_id, value = value, add_time = long(time.time()))
        session = DBSession()
        session.add(obj)
        session.commit()
        session.close()
        return True
開發者ID:hellowego,項目名稱:auto,代碼行數:7,代碼來源:captchaModel.py

示例11: addAnswerVote

    def addAnswerVote(cls, answer_id, answer_uid, vote_uid, vote_value):
        obj = cls(answer_id = answer_id, answer_uid = answer_uid, vote_uid = vote_uid, add_time = long(time.time()), vote_value = vote_value, reputation_factor = 1)
        session = DBSession()
        session.add(obj)
        session.commit()
        session.close()
        return True
開發者ID:euzhang,項目名稱:auto,代碼行數:7,代碼來源:answerVote_models.py

示例12: add

    def add(cls, name, url):
        obj = cls(uid = uid, name = name, url = url, add_time = long(time.time()))
        session = DBSession()
        session.add(obj)
        session.commit()
        session.close()
        return True
開發者ID:hellowego,項目名稱:auto,代碼行數:7,代碼來源:catalogModel.py

示例13: addAnswer

    def addAnswer(cls, questionId, answerContent, userId):
        obj = cls(question_id = questionId, answer_content = answerContent, uid = userId, add_time = long(time.time()))
        session = DBSession()
        session.add(obj)
        session.commit()
        session.close()
        return True
開發者ID:hellowego,項目名稱:auto,代碼行數:7,代碼來源:answer_models.py

示例14: addQuestion

 def addQuestion(cls, question_content, question_detail, published_uid):
     obj = cls(question_content = question_content, question_detail = question_detail, 
         published_uid = published_uid, add_time = long(time.time()), update_time = long(time.time()))
     session = DBSession()
     session.add(obj)
     session.commit()
     session.close()
     return True
開發者ID:hellowego,項目名稱:auto,代碼行數:8,代碼來源:question_models.py

示例15: addUser

    def addUser(cls, username, email, password):
        hashed_password = bcrypt.hashpw(tornado.escape.utf8(password), bcrypt.gensalt())
        print hashed_password
        ret = cls(name = username, email = email, hashed_password = hashed_password)
        session = DBSession()
        session.add(ret)
        session.commit()
        session.close()
        return True
開發者ID:euzhang,項目名稱:auto,代碼行數:9,代碼來源:account_models.py


注:本文中的db.dbSession.DBSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。