本文整理汇总了Python中user.User.get_user_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_user_by_id方法的具体用法?Python User.get_user_by_id怎么用?Python User.get_user_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.get_user_by_id方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_all_comments
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_all_comments(aid,n):
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from comment where aid=%s order by wtime limit %s",[aid,n])
datas = cursor.fetchall()
cursor.close()
conn.close()
comments = []
if len(datas) > 0:
for data in datas:
user = User.get_user_by_id(data[2])[0]
touser = User.get_user_by_id(data[3])[0]
comments.append(Comment(data[0],data[1],data[2],data[3],data[4],data[5],user.uname,user.hpic,touser.uname,touser.hpic))
return comments
示例2: get_all_card
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_all_card():
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from card order by porder desc")
datas = cursor.fetchall()
cursor.close()
conn.close()
cards = []
if len(datas) > 0:
for data in datas:
cards.append(Card(data[0],data[1],data[2],data[3],data[4],User.get_user_by_id(data[3])[0].uname))
return cards
示例3: get_by_fid
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_by_fid(fid):
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from card where fid=%s",[fid])
datas = cursor.fetchall()
cursor.close()
conn.close()
cards = []
if len(datas) > 0:
for data in datas:
cards.append(Card(data[0],data[1],data[2],data[3],data[4],User.get_user_by_id(data[3])))
return cards
示例4: get_by_porder
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_by_porder(porder):
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from card where porder=%s",[porder])
datas = cursor.fetchall()
cursor.close()
conn.close()
cards = []
if len(datas) > 0:
for data in datas:
cards.append(Card(data[0],data[1],data[2],data[3],data[4],User.get_user_by_id(data[3])[0].uname))
return cards
示例5: get_by_fid
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_by_fid(fid):
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from story where fid=%s",[fid])
datas = cursor.fetchall()
cursor.close()
conn.close()
stories = []
if len(datas) > 0:
for data in datas:
stories.append(Story(data[0],data[1],data[2],data[3],data[4],data[5],User.get_user_by_id(data[3])[0].uname))
return stories
示例6: get_all_story
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_all_story():
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from story order by porder desc")
datas = cursor.fetchall()
cursor.close()
conn.close()
stories = []
if len(datas) > 0:
for data in datas:
stories.append(Story(data[0],data[1],data[2],data[3],data[4],data[5],User.get_user_by_id(data[3])))
return stories
示例7: get_article_by_user_focus
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_article_by_user_focus(uid, n):
conn=connect()
cursor=conn.cursor()
cursor.execute("select a.aid, a.class, a.uid, a.cid, a.sid, a.type, a.label, a.title, a.main, a.pic, a.nlove, a.ncomment, a.nvisit, a.wtime from article a, focus f where f.fid=%s and a.uid=f.bfid order by wtime desc limit %s",[uid,n])
datas = cursor.fetchall()
cursor.close()
conn.close()
article = []
if len(datas) > 0:
for data in datas:
user = User.get_user_by_id(data[2])[0]
uname = user.uname
hpic = user.hpic
article.append(Article(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],uname,hpic))
return article
示例8: get_collection
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_collection(uid,n):
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from article where aid in (select aid from collection where uid=%s) order by wtime desc limit %s",[uid,n])
datas = cursor.fetchall()
cursor.close()
conn.close()
article = []
if len(datas) > 0:
for data in datas:
user = User.get_user_by_id(data[2])[0]
uname = user.uname
hpic = user.hpic
article.append(Article(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],uname,hpic))
return article
示例9: get_by_date
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_by_date(date,n):
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from article where wtime like %s order by wtime desc limit %s",['%'+date+'%',n])
datas = cursor.fetchall()
cursor.close()
conn.close()
article = []
if len(datas) > 0:
for data in datas:
user = User.get_user_by_id(data[2])[0]
uname = user.uname
hpic = user.hpic
article.append(Article(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],uname,hpic))
return article
示例10: get_by_aid
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import get_user_by_id [as 别名]
def get_by_aid(aid):
conn=connect()
cursor=conn.cursor()
cursor.execute("select * from article where aid=%s",[aid])
datas = cursor.fetchall()
cursor.close()
conn.close()
article = []
if len(datas) > 0:
for data in datas:
user = User.get_user_by_id(data[2])[0]
uname = user.uname
hpic = user.hpic
article.append(Article(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],uname,hpic))
return article