本文整理汇总了Python中db.dbSession.DBSession.close方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.close方法的具体用法?Python DBSession.close怎么用?Python DBSession.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.dbSession.DBSession
的用法示例。
在下文中一共展示了DBSession.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例2: addAnswerVote
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例3: addAnswer
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例4: add
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例5: add
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例6: addAnswerComment
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例7: addQuestion
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例8: addUser
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例9: queryByUserIdAndLinkId
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
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
示例10: updateVoteByAnswerId
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
def updateVoteByAnswerId(cls, answer_id, type, against_count, agree_count):
session = DBSession()
# 0反对票, 1赞同票
# if type == '-1' :
# print 'update against_count'
# session.query(cls).filter(cls.answer_id == answer_id).update({cls.against_count:count})
# elif type == '1' :
# print 'update agree_count'
# session.query(cls).filter(cls.answer_id == answer_id).update({cls.agree_count:count})
session.query(cls).filter(cls.answer_id == answer_id).update({cls.against_count:against_count, cls.agree_count:agree_count})
session.commit()
session.close()
示例11: unfollow
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
def unfollow(cls, fansUid, friendUid):
''' 取消关注 '''
# 创建session对象:
session = DBSession()
ret = session.query(cls).filter(cls.friend_uid==friendUid, cls.fans_uid==fansUid).delete()
session.commit()
session.close()
# 更新uid为fansUid的关注人数和粉丝数
following = cls.countFollowing(fansUid)
follower = cls.countFollower(fansUid)
Users.updateFollowCount(fansUid, follower, following)
# 更新uid为friendUid的关注人数和粉丝数
following = cls.countFollowing(friendUid)
follower = cls.countFollower(friendUid)
Users.updateFollowCount(friendUid, follower, following)
return True
示例12: follow
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
def follow(cls, fansUid, friendUid):
'''
添加关注
同时更新用户表的粉丝数和关注数
'''
ret = cls(fans_uid = fansUid, friend_uid = friendUid)
session = DBSession()
session.add(ret)
session.commit()
session.close()
# 更新uid为fansUid的关注人数和粉丝数
following = cls.countFollowing(fansUid)
follower = cls.countFollower(fansUid)
Users.updateFollowCount(fansUid, follower, following)
# 更新uid为friendUid的关注人数和粉丝数
following = cls.countFollowing(friendUid)
follower = cls.countFollower(friendUid)
Users.updateFollowCount(friendUid, follower, following)
return True
示例13: updateByVoterId
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
def updateByVoterId(cls, voter_id, vote_value):
session = DBSession()
session.query(cls).filter(cls.voter_id == voter_id).update({cls.vote_value:vote_value})
session.commit()
session.close()
示例14: deleteByUserIdAndLinkId
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
def deleteByUserIdAndLinkId(cls, userId, linkid):
session = DBSession()
session.query(cls).filter(cls.user_id == userId, cls.link_id == linkid).delete()
session.commit()
session.close()
return True
示例15: deleteByAnswerId
# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import close [as 别名]
def deleteByAnswerId(cls, answer_id):
session = DBSession()
session.query(cls).filter(cls.answer_id == answer_id).delete()
session.commit()
session.close()