• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python db.select函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中transwarp.db.select函数的典型用法代码示例。如果您正苦于以下问题:Python select函数的具体用法?Python select怎么用?Python select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: update_timeline

def update_timeline():
    i = ctx.request.input()
    client = _create_client()
    data = client.parse_signed_request(i.signed_request)
    if data is None:
        raise StandardError('Error!')
    user_id = data.get('uid', '')
    auth_token = data.get('oauth_token', '')
    if not user_id or not auth_token:
        return dict(error='bad_signature')
    expires = data.expires
    client.set_access_token(auth_token, expires)

    u = db.select('select since_id from users where id=?', user_id)[0]
    kw = dict(uid=user_id, count=100, trim_user=1)
    since_id = u.since_id
    if since_id:
        kw['since_id'] = since_id

    timeline = client.statuses.user_timeline.get(**kw)
    statuses = timeline.statuses
    count = 0
    if statuses:
        since_id = str(statuses[0].id)
        for st in statuses:
            info = record.parse(st.text)
            if info:
                t, ymd = _parse_datetime(st.created_at)
                r = dict(id=st.id, user_id=user_id, text=st.text, created_at=t, rdistance=info[0], rtime=info[1], rdate=ymd)
                if not db.select('select id from records where id=?', st.id):
                    db.insert('records', **r)
                    count = count + 1
        db.update_kw('users', 'id=?', user_id, since_id = since_id)
    return dict(count=count, since_id=since_id)
开发者ID:JessicaHAN,项目名称:irunning,代码行数:34,代码来源:urls.py


示例2: get_settings

def get_settings(kind=None, remove_prefix=False):
    '''
    Get all settings.
    '''
    settings = dict()
    if kind:
        L = db.select('select name, value from settings where kind=?', kind)
    else:
        L = db.select('select name, value from settings')
    for s in L:
        key = s.name[s.name.find('_')+1:] if remove_prefix else s.name
        settings[key] = s.value
    return settings
开发者ID:a740122,项目名称:itranswarp,代码行数:13,代码来源:util.py


示例3: _init_theme

def _init_theme(path, model):
    theme = get_active_theme()
    model['__theme_path__'] = '/themes/%s' % theme
    model['__get_theme_path__'] = lambda _templpath: 'themes/%s/%s' % (theme, _templpath)
    model['__menus__'] = db.select('select * from menus order by display_order, name')
    model.update(get_settings('site'))
    if not 'site_name' in model:
        model['site_name'] = 'iTranswarp'
    if not '__title__' in model:
        model['__title__'] = model['site_name']
    model['ctx'] = ctx
    model['__layout_categories__'] = db.select('select * from categories order by display_order, name')
    return 'themes/%s/%s' % (theme, path), model
开发者ID:a740122,项目名称:itranswarp,代码行数:13,代码来源:util.py


示例4: get_default_cv

def get_default_cv(uid):
    cvs = None
    while not cvs:
        cvs = db.select('select * from resumes where user_id=?', uid)
        if not cvs:
            cv_id = db.next_str()
            db.insert('resumes', id=cv_id, user_id=uid, title='My Resume', version=0)
            db.insert('sections', id=db.next_str(), user_id=uid, resume_id=cv_id, display_order=0, kind='about', title='About', description='', version=0)

    cv = cvs[0]
    cv.sections = db.select('select * from sections where resume_id=? order by display_order', cv.id)
    for section in cv.sections:
        section.style = _SECTIONS_STYLE[section.kind]
        section.entries = db.select('select * from entries where section_id=? order by display_order', section.id)
    return cv
开发者ID:michaelliao,项目名称:brightercv,代码行数:15,代码来源:resume.py


示例5: featured_poems

def featured_poems():
    total = db.select_int('select count(id) as num from poem where ilike>=100')
    s = set()
    while len(s)<5:
        s.add(random.randint(0, total-1))
    L = []
    for n in s:
        L.extend(db.select('select * from poem where ilike>=100 order by id limit ?,?', n, 1))
    total = db.select_int('select count(id) from poem where ilike<100')
    s = set()
    while len(s)<5:
        s.add(random.randint(0, total-1))
    for n in s:
        L.extend(db.select('select * from poem where ilike<100 order by id limit ?,?', n, 1))
    return dict(poems=L)
开发者ID:michaelliao,项目名称:shi-ci,代码行数:15,代码来源:apis.py


示例6: callback

def callback():
    i = ctx.request.input(code="")
    code = i.code
    client = _create_client()
    r = client.request_access_token(code)
    logging.info("access token: %s" % json.dumps(r))
    access_token, expires_in, uid = r.access_token, r.expires_in, r.uid
    client.set_access_token(access_token, expires_in)
    u = client.users.show.get(uid=uid)
    logging.info("got user: %s" % uid)
    users = db.select("select * from users where id=?", uid)
    user = dict(
        name=u.screen_name,
        image_url=u.avatar_large or u.profile_image_url,
        statuses_count=u.statuses_count,
        friends_count=u.friends_count,
        followers_count=u.followers_count,
        verified=u.verified,
        verified_type=u.verified_type,
        auth_token=access_token,
        expired_time=expires_in,
    )
    if users:
        db.update_kw("users", "id=?", uid, **user)
    else:
        user["id"] = uid
        db.insert("users", **user)
    _make_cookie(uid, access_token, expires_in)
    raise seeother("/")
开发者ID:zhourunlai,项目名称:soulmatetest,代码行数:29,代码来源:urls.py


示例7: get_comments_desc

def get_comments_desc(ref_id, max_results=20, after_id=None):
    '''
    Get comments by page.

    Args:
        ref_id: reference id.
        max_results: the max results.
        after_id: comments after id.
    Returns:
        comments as list.
    '''
    if max_results < 1 or max_results > 100:
        raise ValueError('bad max_results')
    if after_id:
        return db.select('select * from comments where ref_id=? and id < ? order by id desc limit ?', ref_id, after_id, max_results)
    return db.select('select * from comments where ref_id=? order by id desc limit ?', ref_id, max_results)
开发者ID:a740122,项目名称:itranswarp,代码行数:16,代码来源:util.py


示例8: callback

def callback():
    i = ctx.request.input(code='')
    code = i.code
    client = _create_client()
    r = client.request_access_token(code)
    logging.info('access token: %s' % json.dumps(r))
    access_token, expires_in, uid = r.access_token, r.expires_in, r.uid
    client.set_access_token(access_token, expires_in)
    u = client.users.show.get(uid=uid)
    logging.info('got user: %s' % uid)
    users = db.select('select * from users where id=?', uid)
    user = dict(name=u.screen_name, \
            image_url=u.avatar_large or u.profile_image_url, \
            statuses_count=u.statuses_count, \
            friends_count=u.friends_count, \
            followers_count=u.followers_count, \
            verified=u.verified, \
            verified_type=u.verified_type, \
            auth_token=access_token, \
            expired_time=expires_in)
    if users:
        db.update_kw('users', 'id=?', uid, **user)
    else:
        user['id'] = uid
        db.insert('users', **user)
    _make_cookie(uid, access_token, expires_in)
    raise seeother('/')
开发者ID:kaiwang13,项目名称:SOA_HW,代码行数:27,代码来源:urls.py


示例9: find_by

	def find_by(cls, where, *args):
   		'''
   		Find by where clause and return list.
   		'''
   		sql = 'select * from %s where %s' % (cls.__table__, where)

   		d = db.select(sql, *args)
   		return [cls(**i) for l in d]
开发者ID:ujfj1986,项目名称:blog,代码行数:8,代码来源:orm.py


示例10: _get_site

def _get_site(host):
    wss = db.select('select * from websites where domain=?', host)
    if wss:
        ws = wss[0]
        if ws.disabled:
            logging.debug('website is disabled: %s' % host)
            raise forbidden()
        return ws
    raise notfound()
开发者ID:a740122,项目名称:itranswarp,代码行数:9,代码来源:loader.py


示例11: _load_app_info

def _load_app_info():
    global _APP_ID, _APP_SECRET, _ADMIN_PASS
    for s in db.select("select * from settings"):
        if s.id == "app_id":
            _APP_ID = s.value
        if s.id == "app_secret":
            _APP_SECRET = s.value
        if s.id == "admin_pass":
            _ADMIN_PASS = s.value
开发者ID:zhourunlai,项目名称:soulmatetest,代码行数:9,代码来源:urls.py


示例12: archives

def archives():
    years = db.select('select distinct `year` from `blogs` order by created desc')
    if not years:
        raise notfound()
    xblogs = list()
    for y in years:
        blogs = Blogs.find_by('where `year` = ? order by created desc', y.get('year'))
        xblogs.append(blogs)
    return dict(xblogs=xblogs)
开发者ID:1007650105,项目名称:blog,代码行数:9,代码来源:urls.py


示例13: dynasty_page

def dynasty_page(dyn_id):
    '''
    GET /dynasty/{dynasty_id}/{page}
    
    Show dynasty page.
    '''
    dynasty = get_dynasty(dyn_id)
    dynasties = get_dynasties()
    poets = db.select('select * from poet where dynasty_id=? order by pinyin', dyn_id)
    return dict(title=dynasty.name, dynasty=dynasty, dynasties=dynasties, poets=poets)
开发者ID:michaelliao,项目名称:shi-ci,代码行数:10,代码来源:apis.py


示例14: get_text

def get_text(name, default=''):
    '''
    Get text by name. Return default value '' if not exist.
    '''
    ss = db.select('select value from texts where name=?', name)
    if ss:
        v = ss[0].value
        if v:
            return v
    return default
开发者ID:a740122,项目名称:itranswarp,代码行数:10,代码来源:util.py


示例15: get_menus

def get_menus():
    '''
    Get navigation menus as list, each element is a Dict object.
    '''
    menus = db.select('select * from menus order by display_order, name')
    if menus:
        return menus
    current = time.time()
    menu = Dict(id=db.next_str(), name=u'Home', description=u'', type='latest_articles', display_order=0, ref='', url='/latest', creation_time=current, modified_time=current, version=0)
    db.insert('menus', **menu)
    return [menu]
开发者ID:a740122,项目名称:itranswarp,代码行数:11,代码来源:util.py


示例16: _get_Text

def _get_Text(username):
    lb = db.select('select * from labels where username=? and weight>0', username)
    txt = []
    wei = []

    for i in range(0, len(lb)):
        print lb[i]['label']
        txt.append(lb[i]['label'])
        wei.append(lb[i]['weight'])

    return {"text": txt, "weight":wei }
开发者ID:huj690,项目名称:Lovedle,代码行数:11,代码来源:urls.py


示例17: get_poems

def get_poems(poet_id, page=1):
    '''
    Return poems of page N (N=1, 2, 3) and has_next.
    '''
    if page < 1 or page > 100:
        raise ValueError('invalid page.')
    offset = PAGE_SIZE * (page - 1)
    maximum = PAGE_SIZE + 1
    L = db.select('select * from poem where poet_id=? order by name_pinyin limit ?,?', poet_id, offset, maximum)
    if len(L) == maximum:
        return L[:-1], True
    return L, False
开发者ID:michaelliao,项目名称:shi-ci,代码行数:12,代码来源:apis.py


示例18: archives

def archives():
    sql = 'SELECT YEAR(`created`) AS `year`, `id`, `title`, `created` FROM `blogs` ORDER BY `created` DESC'
    blogs = db.select(sql)
    if not blogs:
        raise notfound()
    xblogs = OrderedDict()
    for blog in blogs:
        if not blog['year'] in xblogs:
            xblogs[blog['year']] = [blog]
        else:
            xblogs[blog['year']].append(blog)
    return dict(xblogs=xblogs)
开发者ID:zhu327,项目名称:blog,代码行数:12,代码来源:urls.py


示例19: getUsers

def getUsers():
    u = _check_cookie()
    if u is None:
        return dict(error='failed', redirect='/signin')
    client = _create_client()
    client.set_access_token(u.auth_token, u.expired_time)
    try:
        output = db.select('select * from users')
        result = {'users':output}
        return result
    except APIError, e:
        return dict(error='failed')
开发者ID:kaiwang13,项目名称:SOA_HW,代码行数:12,代码来源:urls.py


示例20: _get_Image

def _get_Image(label, username):
    li = db.select('select id from labels where label=? and username=?', label, username)

    print li

    imgs = db.select('select * from pictures where labelID=?', li[0]['id'])
    src = []
    dec = []

    for i in range(0, len(imgs)):
        full = imgs[i]['picUrl']
        tm = imgs[i]['upTime']

        cn = re.findall('[a-z0-9A-Z]+.jpg', full)
        full = cn[0]

        tm = tm[4:10] + tm[25:30]

        src.append(full)
        dec.append(tm)

    return {"src": src, "dec": dec}
开发者ID:huj690,项目名称:Lovedle,代码行数:22,代码来源:urls.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.notfound函数代码示例发布时间:2022-05-27
下一篇:
Python db.create_engine函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap