本文整理汇总了Python中MysqlObj.getAll方法的典型用法代码示例。如果您正苦于以下问题:Python MysqlObj.getAll方法的具体用法?Python MysqlObj.getAll怎么用?Python MysqlObj.getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MysqlObj
的用法示例。
在下文中一共展示了MysqlObj.getAll方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTags
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getTags(tids):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
if len(tids) == 0:
return {}
res = db.getAll('tags', where=["id in (%s)" % ','.join(['%s' for i in range(0, len(tids))]), tids])
tags = {}
for row in res:
tags[row.id] = row.name
return tags
示例2: getAllTagsCounts
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getAllTagsCounts(uid):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
cur = db.query('select a.tid, a.cnt from (select tid, count(*) as cnt from posts_tags where uid = "%s" group by tid) a where a.cnt > 1' % uid)
result = cur.fetchall()
tcnt = {}
for tid, cnt in result:
tcnt[tid] = cnt
tags = db.getAll('tags')
res = []
for tag in tags:
if tag.id in tcnt:
res.append([tag.id, tag.name, tcnt[tag.id]])
return sorted(res, key=lambda x: x[2], reverse=True)
示例3: getPostsTags
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getPostsTags(pids):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
if len(pids) == 0:
return {}, {}
res = db.getAll('posts_tags', where=["pid in (%s)" % ','.join(['%s' for i in range(0, len(pids))]), pids])
posts_tags = {}
tagids = {}
for row in res:
if not posts_tags.has_key(row.pid):
posts_tags[row.pid] = []
posts_tags[row.pid].append(row.tid)
tagids[row.tid] = 1
return posts_tags, getTags(tagids.keys())
示例4: getAction
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getAction(uid, statdate):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('action', where=['uid=%s and statdate=%s', (uid, statdate)], order=['stattime', 'ASC'])
示例5: getMedicine
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getMedicine(uid):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('medicine', where=['uid=%s', [uid]], order=['statdate', 'ASC'])
示例6: getPasswd
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getPasswd(uid):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('passwd', where=['uid=%s', [uid]], order=['project'])
示例7: getTvshow
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getTvshow(uid):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('tvshow', where=['uid=%s', [uid]], order=['name'])
示例8: getSleep
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getSleep(uid, startdate, enddate):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('sleeps', where=['uid=%s and statdate>=%s and statdate<=%s', (uid, startdate, enddate)], order=['statdate', 'DESC'])
示例9: getPostsByIds
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getPostsByIds(ids):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
if len(ids) == 0:
return []
return db.getAll('posts', where=["id in (%s)" % ','.join(['%s' for i in range(0, len(ids))]), ids])
示例10: getPosts
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getPosts(uid, startpos=0, num=25):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('posts', where=['uid=%s', [uid]], order=['id', 'DESC'], limit=[startpos, num])
示例11: getPostsByTag
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getPostsByTag(tid, uid, startpos=0, num=25):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
posts_tags = db.getAll('posts_tags', where=['tid=%s and uid=%s', [tid, uid]], order=['pid', 'DESC'], limit=[startpos, num])
return getPostsByIds([post_tag.pid for post_tag in posts_tags])
示例12: getUniqRawPosts
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getUniqRawPosts(where=None):
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('uniq_raw_posts', where=where)
示例13: getRawPosts
# 需要导入模块: import MysqlObj [as 别名]
# 或者: from MysqlObj import getAll [as 别名]
def getRawPosts():
db = MysqlObj(host=MYSQL_HOST, db=MYSQL_DB, user=MYSQL_USER, passwd=MYSQL_PASS, port=int(MYSQL_PORT))
return db.getAll('raw_posts')