当前位置: 首页>>代码示例>>Python>>正文


Python expression.null函数代码示例

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


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

示例1: get

    def get(self, input_dict):
        if not self.table.select({f: input_dict.get(f) for f in self.decisionFields}):
            return problem(404, "Not Found", "Requested Required Signoff does not exist")

        try:
            page = int(connexion.request.args.get('page', 1))
            limit = int(connexion.request.args.get('limit', 100))
        except ValueError as msg:
            self.log.warning("Bad input: %s", msg)
            return problem(400, "Bad Request", str(msg))
        offset = limit * (page - 1)

        where_count = [self.table.history.data_version != null()]
        for field in self.decisionFields:
            where_count.append(getattr(self.table.history, field) == input_dict.get(field))
        total_count = self.table.history.count(where=where_count)

        where = [getattr(self.table.history, f) == input_dict.get(f) for f in self.decisionFields]
        where.append(self.table.history.data_version != null())
        revisions = self.table.history.select(
            where=where, limit=limit, offset=offset,
            order_by=[self.table.history.timestamp.desc()]
        )

        return jsonify(count=total_count, required_signoffs=revisions)
开发者ID:catlee,项目名称:balrog,代码行数:25,代码来源:required_signoffs.py

示例2: _network_result_filter_hook

 def _network_result_filter_hook(self, query, filters):
     vals = filters and filters.get(external_net.EXTERNAL, [])
     if not vals:
         return query
     if vals[0]:
         return query.filter((ExternalNetwork.network_id != expr.null()))
     return query.filter((ExternalNetwork.network_id == expr.null()))
开发者ID:ytwxy99,项目名称:neutron,代码行数:7,代码来源:external_net_db.py

示例3: __init__

 def __init__( self, system = null(), module = null(), cType = null() ):
   """ just defines some instance members
   """
   self.system = system
   self.module = module
   self.cType = cType
   self.installationList = []
开发者ID:ahaupt,项目名称:DIRAC,代码行数:7,代码来源:InstalledComponentsDB.py

示例4: __query__

 def __query__(self):
     q = super(NullSelectableSelectFilter, self).__query__()
     arg_name = 'select.{}'.format(self.attribute_name)
     s = self.request_args.get(arg_name, self.default)
     if s == self.NULL:
         q = self.attribute.is_(null())
     elif s == self.NOT_NULL:
         q = self.attribute.isnot(null())
     return q
开发者ID:spoqa,项目名称:dodotable,代码行数:9,代码来源:condition.py

示例5: geoname_roundup

    def geoname_roundup():

        Session = create_session(check=True, **session_args)
        session = Session()
        insert = Insert(session)
        Session = create_session(check=False, database='CtyOD')
        insert.ctyod = Session()

        # Roundup addresses in the from_address position, to intersect with next query
        subquery = (
            session.query(Movement.id)
            .outerjoin(
                Association,
                and_(
                    Movement.from_address_id == Association.address_id,
                    Movement.to_address_id == Association.to_address_id,
                    )
                )
            .filter(Association.premises_id == null())
            .subquery()
            )

        # Roundup addresses in the to_address position
        query = (
            session.query(Movement.from_address_id, Movement.to_address_id)
            .outerjoin(
                Association,
                and_(
                    Movement.to_address_id == Association.address_id,
                    Movement.from_address_id == Association.from_address_id,
                    )
                )
            .filter(Association.premises_id == null())
            .join(subquery, Movement.id == subquery.c.movement_id)
            .group_by(Movement.from_address_id, Movement.to_address_id)
            )

        for movement in query:
            from_address = (
                session.query(Address)
                .filter_by(id=movement.from_address_id)
                .one()
                )
            to_address = (
                session.query(Address)
                .filter_by(id=movement.to_address_id)
                .one()
                )
            try:
                insert.premises(from_address, to_address)
                insert.session.commit()
            except:
                insert.session.rollback()

        insert.session.close()
        insert.ctyod.close()
开发者ID:bansallab,项目名称:roundup-db,代码行数:56,代码来源:update_movement.py

示例6: get

    def get(self, sc_id):
        if not self.table.scheduled_changes.select({"sc_id": sc_id}):
            return Response(status=404, response="Scheduled change does not exist")

        try:
            page = int(request.args.get('page', 1))
            limit = int(request.args.get('limit', 100))
            assert page >= 1
        except (ValueError, AssertionError) as msg:
            self.log.warning("Bad input: %s", msg)
            return Response(status=400, response=json.dumps({"exception": msg}))

        offset = limit * (page - 1)
        total_count = self.table.scheduled_changes.history.t.count()\
            .where(self.table.scheduled_changes.history.sc_id == sc_id)\
            .where(self.table.scheduled_changes.history.data_version != null())\
            .execute()\
            .fetchone()[0]

        # Although Scheduled Changes are stored across two tables, we don't
        # expose that through the API. Because of this, we need to look up
        # history in both and return the combined version.
        # This is done by the database layer for non-history parts of Scheduled Changes, but
        # that's not feasible for History due to the inheritance structure of the tables,
        # so we do it here instead.
        revisions = self.table.scheduled_changes.history.select(
            where=[self.table.scheduled_changes.history.sc_id == sc_id,
                   self.table.scheduled_changes.history.data_version != null()],
            limit=limit,
            offset=offset,
            order_by=[self.table.scheduled_changes.history.timestamp.desc()],
        )
        # There's a big 'ol assumption here that the primary Scheduled Changes
        # table and the conditions table always keep their data version in sync.
        for r in revisions:
            cond = self.table.scheduled_changes.conditions.history.select(
                where=[self.table.scheduled_changes.conditions.history.sc_id == r["sc_id"],
                       self.table.scheduled_changes.conditions.history.data_version == r["data_version"]],
            )
            r.update(cond[0])

        ret = {
            "count": total_count,
            "revisions": [],
        }

        for rev in revisions:
            r = {}
            for k, v in rev.iteritems():
                if k == "data_version":
                    r["sc_data_version"] = v
                else:
                    r[k.replace("base_", "")] = v
            ret["revisions"].append(r)

        return jsonify(ret)
开发者ID:nurav,项目名称:balrog,代码行数:56,代码来源:scheduled_changes.py

示例7: visit_binary

 def visit_binary(binary):
     mapper = reverse_direction and self.parent_property.mapper or self.parent_property.parent
     if isinstance(binary.left, expression._BindParamClause) and binary.left.key in bind_to_col:
         # reverse order if the NULL is on the left side
         binary.left = binary.right
         binary.right = expression.null()
         binary.operator = operators.is_
     elif isinstance(binary.right, expression._BindParamClause) and binary.right.key in bind_to_col:
         binary.right = expression.null()
         binary.operator = operators.is_
开发者ID:Frihet,项目名称:sqlalchemy-patches,代码行数:10,代码来源:strategies.py

示例8: visit_binary

 def visit_binary(binary):
     if isinstance(binary.left, expression._BindParamClause) and binary.left._identifying_key in nulls:
         # reverse order if the NULL is on the left side
         binary.left = binary.right
         binary.right = expression.null()
         binary.operator = operators.is_
         binary.negate = operators.isnot
     elif isinstance(binary.right, expression._BindParamClause) and binary.right._identifying_key in nulls:
         binary.right = expression.null()
         binary.operator = operators.is_
         binary.negate = operators.isnot
开发者ID:pszafer,项目名称:dlna_upnp_invention,代码行数:11,代码来源:util.py

示例9: get

    def get(self, release):
        releases = dbo.releases.getReleases(name=release, limit=1)
        if not releases:
            return Response(status=404,
                            response='Requested release does not exist')
        release = releases[0]
        table = dbo.releases.history

        try:
            page = int(request.args.get('page', 1))
            limit = int(request.args.get('limit', 10))
            assert page >= 1
        except (ValueError, AssertionError) as e:
            self.log.warning("Bad input: %s", json.dumps(e.args))
            return Response(status=400, response=json.dumps({"data": e.args}))
        offset = limit * (page - 1)
        total_count = table.t.count()\
            .where(table.name == release['name'])\
            .where(table.data_version != null())\
            .execute()\
            .fetchone()[0]

        revisions = table.select(
            where=[
                table.name == release['name'],
                table.data_version != null()
            ],
            limit=limit,
            offset=offset,
            order_by=[table.timestamp.desc()],
        )

        _mapping = [
            'data_version',
            'name',
            'product',
            'read_only',
            '_different',
            '_time_ago',
            'change_id',
            'changed_by',
            "timestamp",
        ]

        self.annotateRevisionDifferences(revisions)

        _revisions = []
        for r in revisions:
            _revisions.append(dict(
                (item, r[item])
                for item in _mapping
            ))

        return jsonify(revisions=_revisions, count=total_count)
开发者ID:nurav,项目名称:balrog,代码行数:54,代码来源:releases.py

示例10: _get_filters

def _get_filters(obj, history_table):
    query = get_input_dict()
    where = [False, False]
    where = [getattr(history_table, f) == query.get(f) for f in query]
    where.append(history_table.data_version != null())
    if hasattr(history_table, 'product'):
        where.append(history_table.product != null())
    if request.args.get('timestamp_from'):
        where.append(history_table.timestamp >= int(request.args.get('timestamp_from')))
    if request.args.get('timestamp_to'):
        where.append(history_table.timestamp <= int(request.args.get('timestamp_to')))
    return where
开发者ID:njirap,项目名称:balrog,代码行数:12,代码来源:history_all.py

示例11: _get_filters

 def _get_filters(self):
     query = get_input_dict()
     where = [getattr(self.table.history, f) == query.get(f) for f in query]
     where.append(self.table.history.data_version != null())
     if hasattr(self.history_table, 'product'):
         where.append(self.history_table.product != null())
     request = connexion.request
     if request.args.get('timestamp_from'):
         where.append(self.history_table.timestamp >= int(request.args.get('timestamp_from')))
     if request.args.get('timestamp_to'):
         where.append(self.history_table.timestamp <= int(request.args.get('timestamp_to')))
     return where
开发者ID:njirap,项目名称:balrog,代码行数:12,代码来源:required_signoffs.py

示例12: avg_ct

 def avg_ct(self, cell_line):
     from collections import Iterable
     from sqlalchemy.sql.expression import null
     if self.ctoxicity:
         if isinstance(self.ctoxicity, Iterable):
             values = [ct.ic50 for ct in self.ctoxicity if ct.cell_line == cell_line and ct.active]
         else:
             values = null()
         try:
             self._avg_ct = round(sum(values)/len(values), 4)
         except ZeroDivisionError:
             self._avg_ct = null() # the default value
     else:
         self._avg_ct = null()
开发者ID:admed,项目名称:molgears,代码行数:14,代码来源:compounds.py

示例13: filter

 def filter( self, trans, user, query, column_filter ):
     """ Modify query to filter histories by sharing status. """
     if column_filter == "All":
         pass
     elif column_filter:
         if column_filter == "private":
             query = query.filter( self.model_class.users_shared_with == null() )
             query = query.filter( self.model_class.importable == false() )
         elif column_filter == "shared":
             query = query.filter( self.model_class.users_shared_with != null() )
         elif column_filter == "accessible":
             query = query.filter( self.model_class.importable == true() )
         elif column_filter == "published":
             query = query.filter( self.model_class.published == true() )
     return query
开发者ID:AbhishekKumarSingh,项目名称:galaxy,代码行数:15,代码来源:grids.py

示例14: _story_build_summary_query

def _story_build_summary_query():
    # first create a subquery for task statuses
    select_items = []
    select_items.append(Story)
    select_items.append(
        expr.case(
            [(func.sum(Task.status.in_(
                ['todo', 'inprogress', 'review'])) > 0,
              'active'),
             ((func.sum(Task.status == 'merged')) > 0, 'merged')],
            else_='invalid'
        ).label('status')
    )
    for task_status in Task.TASK_STATUSES:
        select_items.append(expr.cast(
            func.sum(Task.status == task_status), Integer
        ).label(task_status))
    select_items.append(expr.null().label('task_statuses'))

    result = select(select_items, None,
                    expr.Join(Story, Task, onclause=Story.id == Task.story_id,
                              isouter=True)) \
        .group_by(Story.id) \
        .alias('story_summary')

    return result
开发者ID:devcurmudgeon,项目名称:storyboard,代码行数:26,代码来源:models.py

示例15: get_data_sources

def get_data_sources(data_source, start_date, finish_date, forecast_date=None):

    if forecast_date is None:
        forecast_date = data_source.forecast_date

    if data_source.start_date == start_date and \
            data_source.finish_date == finish_date \
            and forecast_date == data_source.forecast_date:
        yield data_source
    else:
        for g_era in data_source.sess.query(GEra).filter(
                GEra.g_supply == data_source.g_supply,
                GEra.start_date <= finish_date,
                or_(
                    GEra.finish_date == null(),
                    GEra.finish_date >= start_date)):
            g_era_start = g_era.start_date

            if start_date < g_era_start:
                chunk_start = g_era_start
            else:
                chunk_start = start_date

            g_era_finish = g_era.finish_date

            chunk_finish = g_era_finish if \
                hh_after(finish_date, g_era_finish) else finish_date

            ds = GDataSource(
                data_source.sess, chunk_start, chunk_finish, forecast_date,
                g_era, data_source.caches, data_source.bill)
            yield ds
开发者ID:JuviAndaya,项目名称:chellow,代码行数:32,代码来源:g_engine.py


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