本文整理汇总了Python中app.db.DBApiModule.insertToTable方法的典型用法代码示例。如果您正苦于以下问题:Python DBApiModule.insertToTable方法的具体用法?Python DBApiModule.insertToTable怎么用?Python DBApiModule.insertToTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.db.DBApiModule
的用法示例。
在下文中一共展示了DBApiModule.insertToTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addLink
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def addLink(form, userId):
linkId = utils.uuid()
kwargs = {}
kwargs["id"] = linkId
kwargs["user_id"] = userId
if form.has_key("url") :
kwargs["url"]=form["url"]
kwargs["url_hash"] = hashlib.md5(kwargs["url"]).hexdigest()
else:
raise Exception("an url must be added")
if form.has_key("title"):
kwargs["title"]=form["title"]
if form.has_key("description"):
kwargs["description"]=form["description"]
if form.has_key("typeName"):
kwargs["type_name"]=form["typeName"]
kwargs["modified_at"]=utils.timeStamp()
#FIXME use other algorithms to get icon logo
iconUrl = utils.extractHomeUrl(kwargs["url"])+"favicon.ico"
conn = db.connect()
db.insertToTable(conn,
"link",
**kwargs)
MetaData.addIconUrl(linkId, iconUrl)
return kwargs
示例2: createUser
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def createUser(userForm):
conn = db.connect()
userId = str(uuid.uuid4())
db.insertToTable(conn, "user",
id=userId,
name=userForm["username"],
email=userForm["email"])
return userId
示例3: createPasswordForUser
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def createPasswordForUser(userId, password):
conn = db.connect()
value = hashlib.sha256(password).hexdigest()
salt = hashlib.sha256(value+userId).hexdigest()
db.insertToTable(conn, "pw_hash",
user_id=userId,
value=value,
salt=salt)
return True
示例4: testInsertNoTypeName
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def testInsertNoTypeName(self):
db.insertToTable(self.conn, "link",
id=self.id,
user_id=self.userId,
url=self.url,
url_hash=self.urlHash,
title=self.title,
description=self.desc,
modified_at=self.modifiedAt)
示例5: create
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def create(userId, name, public):
conn = db.connect()
if public == "true":
public = "1"
else:
public = "0"
count = db.insertToTable(conn, "link_group", id=str(uuid.uuid4()), user_id=userId, name=name, public=public)
return count
示例6: create
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def create(userId, name):
conn = db.connect()
count = db.insertToTable(conn, "tag", id=str(uuid.uuid4()), name=name, user_id=userId)
return count
示例7: tagLink
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def tagLink(linkId, tagId):
conn = db.connect()
count = db.insertToTable(conn, "link_tag_map", tag_id=tagId, link_id=linkId)
return count
示例8: add_user
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def add_user(self):
conn = db.connect()
db.insertToTable(conn, "table", id = self.id, name = self.username, email = self.email)
示例9: testInsertNoText
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def testInsertNoText(self):
db.insertToTable(self.conn, "search_table",
user_id=self.userId,
link_id=self.linkId,
groups=self.groups,
tags=self.tags)
示例10: testInsertNoGroups
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def testInsertNoGroups(self):
db.insertToTable(self.conn, "search_table",
user_id=self.userId,
link_id=self.linkId,
tags=self.tags,
text=self.text)
示例11: insertPW
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def insertPW(self, userId, value, salt):
db.insertToTable(self.conn, "pw_hash", user_id=userId,
value=value, salt=salt)
示例12: insertUser
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def insertUser(self, _id, name, email):
db.insertToTable(self.conn, "user",
id=_id, name=name, email=email)
示例13: groupLink
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def groupLink(linkId, groupId):
conn = db.connect()
count = db.insertToTable(conn, "link_group_map", group_id=groupId, link_id=linkId)
return count
示例14: insertGroup
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def insertGroup(self, _id, name, public):
db.insertToTable(self.conn, "link_group", id=_id, name=name, public=str(public))
示例15: insertLinkTagMap
# 需要导入模块: from app.db import DBApiModule [as 别名]
# 或者: from app.db.DBApiModule import insertToTable [as 别名]
def insertLinkTagMap(self, tagId, linkId):
db.insertToTable(self.conn, "link_tag_map", tag_id=tagId,
link_id=linkId)