本文整理汇总了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
示例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
示例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
示例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
示例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'
示例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'
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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