当前位置: 首页>>代码示例>>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;未经允许,请勿转载。