当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.commit方法代码示例

本文整理汇总了Python中db.dbSession.DBSession.commit方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.commit方法的具体用法?Python DBSession.commit怎么用?Python DBSession.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.dbSession.DBSession的用法示例。


在下文中一共展示了DBSession.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:hellowego,项目名称:auto,代码行数:9,代码来源:captchaModel.py

示例2: addAnswerVote

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:euzhang,项目名称:auto,代码行数:9,代码来源:answerVote_models.py

示例3: addAnswer

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:hellowego,项目名称:auto,代码行数:9,代码来源:answer_models.py

示例4: add

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:hellowego,项目名称:auto,代码行数:9,代码来源:catalogModel.py

示例5: add

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:hellowego,项目名称:auto,代码行数:9,代码来源:user_vote_model.py

示例6: addAnswerComment

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:euzhang,项目名称:auto,代码行数:9,代码来源:answerComment_models.py

示例7: addQuestion

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:hellowego,项目名称:auto,代码行数:10,代码来源:question_models.py

示例8: addUser

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:euzhang,项目名称:auto,代码行数:11,代码来源:account_models.py

示例9: updateVoteByAnswerId

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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()
开发者ID:hellowego,项目名称:auto,代码行数:14,代码来源:answer_models.py

示例10: unfollow

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:hellowego,项目名称:auto,代码行数:21,代码来源:userFollow_models.py

示例11: follow

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [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
开发者ID:hellowego,项目名称:auto,代码行数:24,代码来源:userFollow_models.py

示例12: AutoUser

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [as 别名]
import sys
sys.path.append("..")
from db.dbSession import BaseModel, DBSession
from sqlalchemy import Column, String, Integer

class AutoUser(BaseModel):
    """
    user model
    """
    __tablename__ = 'authors'

    id = Column(Integer, primary_key=True, nullable=False)
    name = Column(String(64), nullable=False)
    hashed_password = Column(String(64), nullable=False)
    email = Column(String(64), nullable=False)



if __name__ == "__main__":
	# 创建session对象:
	session = DBSession()
	# 创建新User对象:
	new_user = AutoUser(id='6', name='Bob', hashed_password='ok', email = '[email protected]')
	# 添加到session:
	session.add(new_user)
	# 提交即保存到数据库:
	session.commit()
	# 关闭session:
	session.close()

开发者ID:euzhang,项目名称:auto,代码行数:31,代码来源:user_models.py

示例13: deleteByVoterId

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [as 别名]
	def deleteByVoterId(cls, voter_id):
		session = DBSession()
		session.query(cls).filter(cls.voter_id == voter_id).delete()
		session.commit()
		session.close()
开发者ID:euzhang,项目名称:auto,代码行数:7,代码来源:answerVote_models.py

示例14: updateFollowCount

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [as 别名]
	def updateFollowCount(cls, uid, fans_count, friend_count):
		session = DBSession()
		session.query(cls).filter(cls.uid == uid).update({cls.fans_count:fans_count, cls.friend_count:friend_count})
		session.commit()
		session.close()
开发者ID:hellowego,项目名称:auto,代码行数:7,代码来源:users_models.py

示例15: updateByUserIdAndLinkId

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import commit [as 别名]
	def updateByUserIdAndLinkId(cls, userId, linkid, type):
		session = DBSession()
		session.query(cls).filter(cls.user_id == userId, cls.link_id == linkid).update({cls.type: type})
		session.commit()
		session.close()
		return True
开发者ID:hellowego,项目名称:auto,代码行数:8,代码来源:user_vote_model.py


注:本文中的db.dbSession.DBSession.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。