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

Python sqlalchemy.func函数代码示例

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

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



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

示例1: get_census_profile

def get_census_profile(geo_code, geo_level):
    session = get_session()

    try:
        geo_summary_levels = get_summary_geo_info(geo_code, geo_level, session)
        data = {}

        for section in PROFILE_SECTIONS:
            function_name = 'get_%s_profile' % section
            if function_name in globals():
                func = globals()[function_name]
                data[section] = func(geo_code, geo_level, session)

                # get profiles for province and/or country
                for level, code in geo_summary_levels:
                    # merge summary profile into current geo profile
                    merge_dicts(data[section], func(code, level, session), level)

        # tweaks to make the data nicer
        # show X largest groups on their own and group the rest as 'Other'
        group_remainder(data['households']['roofing_material_distribution'], 5)
        group_remainder(data['households']['wall_material_distribution'], 5)

        return data

    finally:
        session.close()
开发者ID:callmealien,项目名称:wazimap_zambia,代码行数:27,代码来源:census.py


示例2: get_census_profile

def get_census_profile(geo_code, geo_level):
    session = get_session()

    try:
        geo_summary_levels = get_summary_geo_info(geo_code, geo_level, session)
        data = {}

        for section in PROFILE_SECTIONS:
            function_name = 'get_%s_profile' % section
            if function_name in globals():
                func = globals()[function_name]
                data[section] = func(geo_code, geo_level, session)

                # get profiles for province and/or country
                for level, code in geo_summary_levels:
                    # merge summary profile into current geo profile
                    merge_dicts(data[section], func(code, level, session), level)

        # tweaks to make the data nicer
        # show 3 largest groups on their own and group the rest as 'Other'
        group_remainder(data['service_delivery']['water_source_distribution'])
        group_remainder(data['service_delivery']['refuse_disposal_distribution'])
        group_remainder(data['service_delivery']['toilet_facilities_distribution'], 5)
        group_remainder(data['demographics']['language_distribution'], 7)
        
        return data

    finally:
        session.close()
开发者ID:233,项目名称:censusreporter,代码行数:29,代码来源:census.py


示例3: _initMappers

 def _initMappers(self, version = None):
     """
     Init database mappers.
     """
     if version == None:
         version = self.getUptodateVersion()
     func = getattr(self, "_initMappers" + self.config.auditdbdriver + "V" + str(version))
     func()
开发者ID:tekmans,项目名称:mmc,代码行数:8,代码来源:writers.py


示例4: wrapper

 def wrapper(self, *args, **kwArgs):
     try:
         return func(self, *args, **kwArgs)
     except (MPDError, OSError) as ex:
         logger.warning('Detect MPD connection error; reconnecting...')
         logger.debug(ex)
         self._mpd = initialize_mpd(self.conf)
         return func(self, *args, **kwArgs)
开发者ID:thesquelched,项目名称:suggestive,代码行数:8,代码来源:mstat.py


示例5: _populateTables

 def _populateTables(self, version = None):
     """
     Populate tables before the first use.
     """
     if version == None:
         version = self.getUptodateVersion()
     func = getattr(self, "_populateTables" + self.config.auditdbdriver + "V" + str(version))
     func()
开发者ID:tekmans,项目名称:mmc,代码行数:8,代码来源:writers.py


示例6: decorated_function

 def decorated_function(*args, **kwargs):
     callback = request.args.get('callback', False)
     if callback:
         data = str(func(*args, **kwargs).data)
         content = str(callback) + '(' + data + ')'
         mimetype = 'application/javascript'
         return current_app.response_class(content, mimetype=mimetype)
     else:
         return func(*args, **kwargs)
开发者ID:andylolz,项目名称:IATI-Data-Quality,代码行数:9,代码来源:api.py


示例7: wrapper

 def wrapper(*args, **kwargs):
     if not kwargs.get('session'):
         kwargs['session'] = Session(autoflush=True, expire_on_commit=False)
         try:
             result = func(*args, **kwargs)
             kwargs['session'].commit()
             return result
         finally:
             kwargs['session'].close()
     else:
         return func(*args, **kwargs)
开发者ID:StunMan,项目名称:Flexget,代码行数:11,代码来源:database.py


示例8: call

        def call(db, *args, **kwargs):
            # if the Database has an active session, don't create a new one
            if db.session is not None:
                result = func(db, *args, **kwargs)
                if commit:
                    db.session.commit()
            else:
                # otherwise, use the session generator
                with db_session(db, commit=commit):
                    result = func(db, *args, **kwargs)

            return result
开发者ID:wuqixiaobai,项目名称:ATM,代码行数:12,代码来源:database.py


示例9: do_task

 def do_task(self, args):
     if args['func'] == 'seq':
         func = self._calculate_seq_stats
     elif args['func'] == 'clone':
         func = self._calculate_clone_stats
     self.info(('Processing {} for sample {}, include_outliers {}, '
                'only_full_reads {}').format(
                'sequences' if args['func'] == 'seq' else 'clones',
                args['sample_id'], args['include_outliers'],
                args['only_full_reads']))
     func(args['sample_id'], args['min_cdr3'], args['max_cdr3'],
          args['include_outliers'], args['only_full_reads'])
     self._session.commit()
开发者ID:DrexelSystemsImmunologyLab,项目名称:immunedb,代码行数:13,代码来源:sample_stats.py


示例10: wrapper

    def wrapper(**kwargs):
        #Only track user id if they are authenticated
        if current_user.is_authenticated:
            user_id = current_user.id
        else:
            user_id = None

        #Get session id if it exists; Reminder, session id lasts 8 years or until cookies are deleted
        session_id = session.get('FVID')

        # Get To URL
        base_url = request.base_url

        # Get From Url
        referrer_url = request.referrer if request.referrer else 'None'

        # get user agent
        user_agent = request.headers.get('User-Agent')

        # If no session data, then create new session data
        if session.get('FVID') is None:
            session['FVID'] = secrets.token_hex(32)
            session_id = session.get('FVID')

        # If user is clicking an outbound link, track this instead out /outboundLinks
        to_url = request.args.get('url', default=None, type=None) if base_url == request.url_root + 'outboundLinks' else base_url
        pv = userPageView(session_id = session_id, from_page = referrer_url, to_page = to_url, user_id = user_id, user_agent = user_agent)
        if track_pageviews:
            db.session.add(pv)
            db.session.commit()
        else:
            print(pv)
        x = func(**kwargs)
        return x
开发者ID:RichWolff,项目名称:rwolff,代码行数:34,代码来源:routes.py


示例11: with_group_checking

 def with_group_checking(self, message):
     if message.chat.id < 0:
         self.bot.sendMessage(
             chat_id=message.chat.id, text="這個功能沒辦法在聊天室使用,請跟我私聊。", reply_to_message_id=message.message_id
         )
         return
     return func(self, message)
开发者ID:medicalwei,项目名称:floweybot,代码行数:7,代码来源:main.py


示例12: wrapper

 def wrapper(*args, **kwargs):
     if not 'uid' in session:
         abort(403)
     user = request.user = User.query.filter_by(name=session['uid']).first()
     if getattr(Perms, kwargs.get(request.method, defaccess_or_fn)) not in user.role:
         abort(403)
     return func(*args, **kwargs)
开发者ID:metaxy,项目名称:ipa,代码行数:7,代码来源:server.py


示例13: _execute_async_action

 def _execute_async_action(self, func, *args):
     self.log.info('Scheduling syncback action', func=func, args=args)
     g = gevent.Greenlet(retry_with_logging, lambda: func(*args),
                         logger=self.log)
     g.link_value(lambda _: self.log.info('Syncback action completed',
                                          func=func, args=args))
     self.worker_pool.start(g)
开发者ID:betoflakes,项目名称:inbox,代码行数:7,代码来源:actions.py


示例14: run_hash

    def run_hash():
        # Timestamp is the key
        # Because it is better than pure integers
        now = datetime.datetime.now()
        # Generate salt
        salt = os.urandom(1024)
        salt = base64.b64encode(salt)
        # The final key
        combination = str(now) + str(salt)

        # Use corresponding algorithm for specified required length
        # Provides better hash and avoid collisions
        if length == 32:
            func = hashlib.md5
        elif length == 40:
            func = hashlib.sha1
        elif length == 56:
            func = hashlib.sha224
        elif length == 64:
            func = hashlib.sha256
        elif length == 96:
            func = hashlib.sha384
        else:
            func = hashlib.sha512
        hashid = func(combination).hexdigest()
        return unicode(hashid[:length])
开发者ID:hackweekday,项目名称:HW2012KUL,代码行数:26,代码来源:models.py


示例15: inner

 def inner(env, *a, **kw):
     key = env.request.full_path
     value = cache.get(key)
     if value is None:
         value = func(env, *a, **kw)
         cache.set(key, value, timeout=timeout)
     return value
开发者ID:cybernetics,项目名称:namail,代码行数:7,代码来源:views.py


示例16: _

 def _(user_obj, *args, **kwargs):
     if not user_obj.is_active:
         return False
     elif user_obj.is_superuser:
         return True
     else:
         return func(user_obj, *args, **kwargs)
开发者ID:thrbowl,项目名称:testbox,代码行数:7,代码来源:__init__.py


示例17: get_user_list_info

 def get_user_list_info(self, listof_screen_name=None, listof_user_id=None, **kwargs):
     process_name = "/users/show/:id"
     try:
         user_list = list()
         if listof_screen_name is None:
             for item in listof_user_id:
                 user_id = self.get_user_info(user_id=item)[0]
                 user_list.append(user_id)
         elif listof_user_id is None:
             raise Exception('Unknown Input')
         else:
             for item in listof_screen_name:
                 user_id = self.get_user_info(screen_name=item)[0]
                 user_list.append(user_id)
     except TwitterError as e:
         """ Error처리는 다른 함수와 동일
         """
         sess = Session()
         t = TweetErrorHandler(e)
         t.add_handler(ErrorNumbers.RATE_LIMIT_ERROR, self.rate_limit_handler)
         result = t.invoke(process_name=process_name)
         sess.commit()
         sess.close()
         return result 
     return func(self, user_list, **kwargs)
开发者ID:widian,项目名称:twitter-analysis,代码行数:25,代码来源:crawler.py


示例18: wrapper

 def wrapper(*args, **kwargs):
     if not "user_id" in flask.session:
         flask.flash("Sorry, you are not allowed to do that. "
                     "Please log in first.")
         flask.session["real_url"] = flask.request.url
         return flask.redirect(flask.url_for("login"))
     return func(*args, **kwargs)
开发者ID:aether-space,项目名称:schrift,代码行数:7,代码来源:schrift.py


示例19: wrapper

 def wrapper(*args, **kwargs):
     result = json.dumps(func(*args, **kwargs) or {"error": "No data found for your request"},
                         default=serialize_to_json)
     headers = [
         ("Content-Type", "application/json"),
         ("Content-Length", str(len(result)))
     ]
     return Response(result, status=200, headers=headers)
开发者ID:jmaher,项目名称:ouija,代码行数:8,代码来源:server.py


示例20: wrapper

 def wrapper(*args, **kwargs):
     html = func(*args, **kwargs)
     if request.args.get('download'):
         page = kwargs.get('page')
         dataset_id = kwargs.get('dataset_id')
         report_name = get_report_name(page, dataset_id)
         return get_excel_document(html, report_name)
     return html
开发者ID:eaudeweb,项目名称:art17-consultation,代码行数:8,代码来源:reports.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sqlalchemy.inspect函数代码示例发布时间:2022-05-27
下一篇:
Python sqlalchemy.false函数代码示例发布时间: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