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


Python sqlalchemy.not_方法代码示例

本文整理汇总了Python中sqlalchemy.not_方法的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.not_方法的具体用法?Python sqlalchemy.not_怎么用?Python sqlalchemy.not_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy的用法示例。


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

示例1: exposed_delete_old_nu_root_outbound

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def exposed_delete_old_nu_root_outbound():
	'''
	Delete NU outbound links that use the homepage as their referrer.

	Apparently NU was validating the referrer to see if the referring page actually had
	the referring link on it, or /something/.

	Anyways, it's easier to generate a permanent referrer by just pointing it at
	the series page.
	'''


	with db.session_context() as sess:

		for row in sess.query(db.NuReleaseItem) \
			.filter(not_(db.NuReleaseItem.referrer.like("%novelupdates.com/series%"))) \
			.yield_per(50).all():
			if not len(list(row.resolved)):
				print(row.id, row.referrer)
				sess.delete(row)
				sess.commit() 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:23,代码来源:offline_filters.py

示例2: get_quote_by_nick

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def get_quote_by_nick(db, nick, num=False):
    """Returns a formatted quote from a nick, random or selected by number"""

    count_query = select([qtable]) \
        .where(not_(qtable.c.deleted)) \
        .where(qtable.c.nick == nick.lower()) \
        .alias("count") \
        .count()
    count = db.execute(count_query).fetchall()[0][0]

    try:
        num = get_quote_num(num, count, nick)
    except Exception as error_message:
        return error_message

    query = select([qtable.c.time, qtable.c.nick, qtable.c.msg]) \
        .where(not_(qtable.c.deleted)) \
        .where(qtable.c.nick == nick.lower()) \
        .order_by(qtable.c.time) \
        .limit(1) \
        .offset((num - 1))
    data = db.execute(query).fetchall()[0]
    return format_quote(data, num, count) 
开发者ID:TotallyNotRobots,项目名称:CloudBot,代码行数:25,代码来源:quote.py

示例3: get_quote_by_nick_chan

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def get_quote_by_nick_chan(db, chan, nick, num=False):
    """Returns a formatted quote from a nick in a channel, random or selected by number"""
    count_query = select([qtable]) \
        .where(not_(qtable.c.deleted)) \
        .where(qtable.c.chan == chan) \
        .where(qtable.c.nick == nick.lower()) \
        .alias("count") \
        .count()
    count = db.execute(count_query).fetchall()[0][0]

    try:
        num = get_quote_num(num, count, nick)
    except Exception as error_message:
        return error_message

    query = select([qtable.c.time, qtable.c.nick, qtable.c.msg]) \
        .where(not_(qtable.c.deleted)) \
        .where(qtable.c.chan == chan) \
        .where(qtable.c.nick == nick.lower()) \
        .order_by(qtable.c.time) \
        .limit(1) \
        .offset((num - 1))
    data = db.execute(query).fetchall()[0]
    return format_quote(data, num, count) 
开发者ID:TotallyNotRobots,项目名称:CloudBot,代码行数:26,代码来源:quote.py

示例4: get_quote_by_chan

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def get_quote_by_chan(db, chan, num=False):
    """Returns a formatted quote from a channel, random or selected by number"""
    count_query = select([qtable]) \
        .where(not_(qtable.c.deleted)) \
        .where(qtable.c.chan == chan) \
        .alias("count") \
        .count()
    count = db.execute(count_query).fetchall()[0][0]

    try:
        num = get_quote_num(num, count, chan)
    except Exception as error_message:
        return error_message

    query = select([qtable.c.time, qtable.c.nick, qtable.c.msg]) \
        .where(not_(qtable.c.deleted)) \
        .where(qtable.c.chan == chan) \
        .order_by(qtable.c.time) \
        .limit(1) \
        .offset((num - 1))
    data = db.execute(query).fetchall()[0]
    return format_quote(data, num, count) 
开发者ID:TotallyNotRobots,项目名称:CloudBot,代码行数:24,代码来源:quote.py

示例5: get_all_pending_cleaning_expiring_in_days

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def get_all_pending_cleaning_expiring_in_days(source, days_to_expire):
    """
    Retrieves all certificates that are available for cleaning, not attached to endpoint,
    and within X days from expiration.

    :param days_to_expire: defines how many days till the certificate is expired
    :param source: the source to search for certificates
    :return: list of pending certificates
    """
    expiration_window = arrow.now().shift(days=+days_to_expire).format("YYYY-MM-DD")
    return (
        Certificate.query.filter(Certificate.sources.any(id=source.id))
        .filter(not_(Certificate.endpoints.any()))
        .filter(Certificate.not_after < expiration_window)
        .all()
    ) 
开发者ID:Netflix,项目名称:lemur,代码行数:18,代码来源:service.py

示例6: get_all_pending_cleaning_issued_since_days

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def get_all_pending_cleaning_issued_since_days(source, days_since_issuance):
    """
    Retrieves all certificates that are available for cleaning: not attached to endpoint, and X days since issuance.

    :param days_since_issuance: defines how many days since the certificate is issued
    :param source: the source to search for certificates
    :return: list of pending certificates
    """
    not_in_use_window = (
        arrow.now().shift(days=-days_since_issuance).format("YYYY-MM-DD")
    )
    return (
        Certificate.query.filter(Certificate.sources.any(id=source.id))
        .filter(not_(Certificate.endpoints.any()))
        .filter(Certificate.date_created > not_in_use_window)
        .all()
    ) 
开发者ID:Netflix,项目名称:lemur,代码行数:19,代码来源:service.py

示例7: resolve

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def resolve(self):
        """Create filter for a particular node of the filter tree"""
        if 'or' not in self.filter_ and 'and' not in self.filter_ and 'not' not in self.filter_:
            value = self.value

            if isinstance(value, dict):
                value = Node(self.related_model, value, self.resource, self.related_schema).resolve()

            if '__' in self.filter_.get('name', ''):
                value = {self.filter_['name'].split('__')[1]: value}

            if isinstance(value, dict):
                return getattr(self.column, self.operator)(**value)
            else:
                return getattr(self.column, self.operator)(value)

        if 'or' in self.filter_:
            return or_(Node(self.model, filt, self.resource, self.schema).resolve() for filt in self.filter_['or'])
        if 'and' in self.filter_:
            return and_(Node(self.model, filt, self.resource, self.schema).resolve() for filt in self.filter_['and'])
        if 'not' in self.filter_:
            return not_(Node(self.model, self.filter_['not'], self.resource, self.schema).resolve()) 
开发者ID:miLibris,项目名称:flask-rest-jsonapi,代码行数:24,代码来源:alchemy.py

示例8: get_source_ids

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def get_source_ids(s, owner, name, op, value, group, type):
    op_attr = get_op_attr(op, value)
    statistic_journal = STATISTIC_JOURNAL_CLASSES[type]
    q = s.query(Source.id). \
        join(statistic_journal). \
        join(StatisticName). \
        filter(StatisticName.name.like(name))
    if owner:
        q = q.filter(StatisticName.owner.like(owner))
    if group is not UNDEF:
        if group:
            q = q.join(ActivityGroup).filter(ActivityGroup.name.ilike(group))
        else:
            q = q.filter(Source.activity_group_id == None)
    if op_attr == 'nlike':  # no way to negate like in a single attribute
        q = q.filter(not_(statistic_journal.value.ilike(value)))
    else:
        q = q.filter(getattr(statistic_journal.value, op_attr)(value))
    return q 
开发者ID:andrewcooke,项目名称:choochoo,代码行数:21,代码来源:constraint.py

示例9: get_source_ids_for_null

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def get_source_ids_for_null(s, owner, name, group, with_conversion):
    q = s.query(StatisticJournal.source_id). \
        join(StatisticName). \
        filter(StatisticName.name.like(name))
    if owner:
        q = q.filter(StatisticName.owner.like(owner))
    if group is not UNDEF:
        if group:
            q = q.join(ActivityGroup).filter(ActivityGroup.name.ilike(group))
        else:
            q = q.join(Source).filter(Source.activity_group_id == None)
    if with_conversion:
        # will invert later (in conversion)
        return q
    else:
        return s.query(Source.id).filter(not_(Source.id.in_(q))) 
开发者ID:andrewcooke,项目名称:choochoo,代码行数:18,代码来源:constraint.py

示例10: activity_conversion

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def activity_conversion(s, source_ids, null):
    # convert the query that gives any source id and select either those that are activities directly,
    # or activities associated with a topic (eg user entered activity notes)

    # for most queries, we have some source IDs and we want to know if they are activityjournal ids
    # (which we pass through) or activitytopicjournal ids (in which case we convert to activityjournal).
    source_ids = source_ids.cte()
    q_direct = s.query(ActivityJournal.id). \
        filter(ActivityJournal.id.in_(source_ids))
    q_via_topic = s.query(ActivityJournal.id). \
        join(FileHash). \
        join(ActivityTopicJournal). \
        filter(ActivityTopicJournal.id.in_(source_ids))
    q = aliased(union(q_direct, q_via_topic)).select()

    if null:
        # for 'is null' queries we are really asking if the data are missing (since values are not null constrained)
        # so we find what does exist and then invert it.  that inversion has to happen avter conversion
        return s.query(ActivityJournal.id).filter(not_(ActivityJournal.id.in_(q)))
    else:
        return q 
开发者ID:andrewcooke,项目名称:choochoo,代码行数:23,代码来源:constraint.py

示例11: test_implicitly_boolean

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def test_implicitly_boolean(self):
        # test for expressions that the database always considers as boolean
        # even if there is no boolean datatype.
        assert not self.table1.c.myid._is_implicitly_boolean
        assert (self.table1.c.myid == 5)._is_implicitly_boolean
        assert (self.table1.c.myid == 5).self_group()._is_implicitly_boolean
        assert (self.table1.c.myid == 5).label("x")._is_implicitly_boolean
        assert not_(self.table1.c.myid == 5)._is_implicitly_boolean
        assert or_(
            self.table1.c.myid == 5, self.table1.c.myid == 7
        )._is_implicitly_boolean
        assert not column("x", Boolean)._is_implicitly_boolean
        assert not (self.table1.c.myid + 5)._is_implicitly_boolean
        assert not not_(column("x", Boolean))._is_implicitly_boolean
        assert (
            not select([self.table1.c.myid])
            .scalar_subquery()
            ._is_implicitly_boolean
        )
        assert not text("x = y")._is_implicitly_boolean
        assert not literal_column("x = y")._is_implicitly_boolean 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_operators.py

示例12: test_or_and_as_columns

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def test_or_and_as_columns(self, connection):
        true, false = literal(True), literal(False)

        eq_(connection.execute(select([and_(true, false)])).scalar(), False)
        eq_(connection.execute(select([and_(true, true)])).scalar(), True)
        eq_(connection.execute(select([or_(true, false)])).scalar(), True)
        eq_(connection.execute(select([or_(false, false)])).scalar(), False)
        eq_(
            connection.execute(select([not_(or_(false, false))])).scalar(),
            True,
        )

        row = connection.execute(
            select(
                [or_(false, false).label("x"), and_(true, false).label("y")]
            )
        ).first()
        assert row.x == False  # noqa
        assert row.y == False  # noqa

        row = connection.execute(
            select([or_(true, false).label("x"), and_(true, false).label("y")])
        ).first()
        assert row.x == True  # noqa
        assert row.y == False  # noqa 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:27,代码来源:test_query.py

示例13: test_in_filtering

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def test_in_filtering(self, connection):
        """test the behavior of the in_() function."""

        connection.execute(users.insert(), user_id=7, user_name="jack")
        connection.execute(users.insert(), user_id=8, user_name="fred")
        connection.execute(users.insert(), user_id=9, user_name=None)

        s = users.select(users.c.user_name.in_([]))
        r = connection.execute(s).fetchall()
        # No username is in empty set
        assert len(r) == 0

        s = users.select(not_(users.c.user_name.in_([])))
        r = connection.execute(s).fetchall()
        assert len(r) == 3

        s = users.select(users.c.user_name.in_(["jack", "fred"]))
        r = connection.execute(s).fetchall()
        assert len(r) == 2

        s = users.select(not_(users.c.user_name.in_(["jack", "fred"])))
        r = connection.execute(s).fetchall()
        # Null values are not outside any set
        assert len(r) == 0 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:26,代码来源:test_query.py

示例14: test_bind_in

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def test_bind_in(self, connection):
        """test calling IN against a bind parameter.

        this isn't allowed on several platforms since we
        generate ? = ?.

        """

        connection.execute(users.insert(), user_id=7, user_name="jack")
        connection.execute(users.insert(), user_id=8, user_name="fred")
        connection.execute(users.insert(), user_id=9, user_name=None)

        u = bindparam("search_key", type_=String)

        s = users.select(not_(u.in_([])))
        r = connection.execute(s, search_key="john").fetchall()
        assert len(r) == 3
        r = connection.execute(s, search_key=None).fetchall()
        assert len(r) == 3 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:test_query.py

示例15: list_quarantined_replicas

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import not_ [as 别名]
def list_quarantined_replicas(rse_id, limit, worker_number=None, total_workers=None, session=None):
    """
    List RSE Quarantined File replicas.

    :param rse_id: the rse id.
    :param limit: The maximum number of replicas returned.
    :param worker_number:      id of the executing worker.
    :param total_workers:      Number of total workers.
    :param session: The database session in use.

    :returns: a list of dictionary replica.
    """

    query = session.query(models.QuarantinedReplica.path,
                          models.QuarantinedReplica.bytes,
                          models.QuarantinedReplica.scope,
                          models.QuarantinedReplica.name,
                          models.QuarantinedReplica.created_at).\
        filter(models.QuarantinedReplica.rse_id == rse_id)

    # do no delete valid replicas
    stmt = exists(select([1]).prefix_with("/*+ index(REPLICAS REPLICAS_PK) */", dialect='oracle')).\
        where(and_(models.RSEFileAssociation.scope == models.QuarantinedReplica.scope,
                   models.RSEFileAssociation.name == models.QuarantinedReplica.name,
                   models.RSEFileAssociation.rse_id == models.QuarantinedReplica.rse_id))
    query = query.filter(not_(stmt))
    query = filter_thread_work(session=session, query=query, total_threads=total_workers, thread_id=worker_number, hash_variable='path')
    return [{'path': path,
             'rse_id': rse_id,
             'created_at': created_at,
             'scope': scope,
             'name': name,
             'bytes': bytes}
            for path, bytes, scope, name, created_at in query.limit(limit)] 
开发者ID:rucio,项目名称:rucio,代码行数:36,代码来源:quarantined_replica.py


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