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


Python DBSession.add方法代码示例

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


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

示例1: add

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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: add

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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

示例3: addAnswer

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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: addAnswerComment

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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

示例5: add

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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: addAnswerVote

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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

示例7: addQuestion

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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 add [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: follow

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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

示例10: AutoUser

# 需要导入模块: from db.dbSession import DBSession [as 别名]
# 或者: from db.dbSession.DBSession import add [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


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