本文整理汇总了Python中sqlalchemy.sql.expression.false方法的典型用法代码示例。如果您正苦于以下问题:Python expression.false方法的具体用法?Python expression.false怎么用?Python expression.false使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.sql.expression
的用法示例。
在下文中一共展示了expression.false方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fill_indexpage_with_archived_books
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def fill_indexpage_with_archived_books(self, page, database, db_filter, order, allow_show_archived, *join):
if current_user.show_detail_random():
randm = self.session.query(Books) \
.filter(self.common_filters(allow_show_archived)) \
.order_by(func.random()) \
.limit(self.config.config_random_books)
else:
randm = false()
off = int(int(self.config.config_books_per_page) * (page - 1))
query = self.session.query(database) \
.join(*join, isouter=True) \
.filter(db_filter) \
.filter(self.common_filters(allow_show_archived))
pagination = Pagination(page, self.config.config_books_per_page,
len(query.all()))
entries = query.order_by(*order).offset(off).limit(self.config.config_books_per_page).all()
for book in entries:
book = self.order_authors(book)
return entries, randm, pagination
# Orders all Authors in the list according to authors sort
示例2: set_rse_usage
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def set_rse_usage(rse_id, source, used, free, session=None):
"""
Set RSE usage information.
:param rse_id: the location id.
:param source: The information source, e.g. srm.
:param used: the used space in bytes.
:param free: the free in bytes.
:param session: The database session in use.
:returns: True if successful, otherwise false.
"""
rse_usage = models.RSEUsage(rse_id=rse_id, source=source, used=used, free=free)
# versioned_session(session)
rse_usage = session.merge(rse_usage)
rse_usage.save(session=session)
# rse_usage_history = models.RSEUsage.__history_mapper__.class_(rse_id=rse.id, source=source, used=used, free=free)
# rse_usage_history.save(session=session)
return True
示例3: __load_distance_edges_node
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def __load_distance_edges_node(rse_id, session=None):
"""
Loads the outgoing edges of the distance graph for one node.
:param rse_id: RSE id to load the edges for.
:param session: The DB Session to use.
:returns: Dictionary based graph object.
"""
result = REGION_SHORT.get('distance_graph_%s' % str(rse_id))
if isinstance(result, NoValue):
distance_graph = {}
for distance in session.query(models.Distance).join(models.RSE, models.RSE.id == models.Distance.dest_rse_id)\
.filter(models.Distance.src_rse_id == rse_id)\
.filter(models.RSE.deleted == false()).all():
if distance.src_rse_id in distance_graph:
distance_graph[distance.src_rse_id][distance.dest_rse_id] = distance.ranking
else:
distance_graph[distance.src_rse_id] = {distance.dest_rse_id: distance.ranking}
REGION_SHORT.set('distance_graph_%s' % str(rse_id), distance_graph)
result = distance_graph
return result
示例4: has_auth_webhooks
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def has_auth_webhooks(user_id):
"""获取所有我有权访问的Webhooks"""
# create webhooks
created_webhooks = WebHook.query.filter_by(
user_id=user_id, deleted=False).all()
# collaborator webhooks
collaborated_webhooks = \
WebHook.query.join(Collaborator,
Collaborator.webhook_id == WebHook.id) \
.filter(Collaborator.user_id == user_id) \
.filter(WebHook.deleted == false()).all()
webhooks = created_webhooks + collaborated_webhooks
# 去重并排序
webhooks = list(sorted(set(webhooks), key=lambda x: x.id, reverse=True))
return webhooks
示例5: upgrade
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('keypairs', sa.Column('is_admin', sa.Boolean(), nullable=False, default=False, server_default=false()))
op.create_index(op.f('ix_keypairs_is_admin'), 'keypairs', ['is_admin'], unique=False)
# ### end Alembic commands ###
示例6: render_hot_books
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def render_hot_books(page):
if current_user.check_visibility(constants.SIDEBAR_HOT):
if current_user.show_detail_random():
random = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()) \
.order_by(func.random()).limit(config.config_random_books)
else:
random = false()
off = int(int(config.config_books_per_page) * (page - 1))
all_books = ub.session.query(ub.Downloads, func.count(ub.Downloads.book_id)).order_by(
func.count(ub.Downloads.book_id).desc()).group_by(ub.Downloads.book_id)
hot_books = all_books.offset(off).limit(config.config_books_per_page)
entries = list()
for book in hot_books:
downloadBook = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()).filter(
db.Books.id == book.Downloads.book_id).first()
if downloadBook:
entries.append(downloadBook)
else:
ub.delete_download(book.Downloads.book_id)
# ub.session.query(ub.Downloads).filter(book.Downloads.book_id == ub.Downloads.book_id).delete()
# ub.session.commit()
numBooks = entries.__len__()
pagination = Pagination(page, config.config_books_per_page, numBooks)
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
title=_(u"Hot Books (Most Downloaded)"), page="hot")
else:
abort(404)
示例7: common_filters
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def common_filters(self, allow_show_archived=False):
if not allow_show_archived:
archived_books = (
ub.session.query(ub.ArchivedBook)
.filter(ub.ArchivedBook.user_id == int(current_user.id))
.filter(ub.ArchivedBook.is_archived == True)
.all()
)
archived_book_ids = [archived_book.book_id for archived_book in archived_books]
archived_filter = Books.id.notin_(archived_book_ids)
else:
archived_filter = true()
if current_user.filter_language() != "all":
lang_filter = Books.languages.any(Languages.lang_code == current_user.filter_language())
else:
lang_filter = true()
negtags_list = current_user.list_denied_tags()
postags_list = current_user.list_allowed_tags()
neg_content_tags_filter = false() if negtags_list == [''] else Books.tags.any(Tags.name.in_(negtags_list))
pos_content_tags_filter = true() if postags_list == [''] else Books.tags.any(Tags.name.in_(postags_list))
if self.config.config_restricted_column:
pos_cc_list = current_user.allowed_column_value.split(',')
pos_content_cc_filter = true() if pos_cc_list == [''] else \
getattr(Books, 'custom_column_' + str(self.config.config_restricted_column)). \
any(cc_classes[self.config.config_restricted_column].value.in_(pos_cc_list))
neg_cc_list = current_user.denied_column_value.split(',')
neg_content_cc_filter = false() if neg_cc_list == [''] else \
getattr(Books, 'custom_column_' + str(self.config.config_restricted_column)). \
any(cc_classes[self.config.config_restricted_column].value.in_(neg_cc_list))
else:
pos_content_cc_filter = true()
neg_content_cc_filter = false()
return and_(lang_filter, pos_content_tags_filter, ~neg_content_tags_filter,
pos_content_cc_filter, ~neg_content_cc_filter, archived_filter)
# Fill indexpage with all requested data from database
示例8: tags_filters
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def tags_filters():
negtags_list = current_user.list_denied_tags()
postags_list = current_user.list_allowed_tags()
neg_content_tags_filter = false() if negtags_list == [''] else db.Tags.name.in_(negtags_list)
pos_content_tags_filter = true() if postags_list == [''] else db.Tags.name.in_(postags_list)
return and_(pos_content_tags_filter, ~neg_content_tags_filter)
# checks if domain is in database (including wildcards)
# example SELECT * FROM @TABLE WHERE 'abcdefg' LIKE Name;
# from https://code.luasoftware.com/tutorials/flask/execute-raw-sql-in-flask-sqlalchemy/
示例9: rse_exists
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def rse_exists(rse, include_deleted=False, session=None):
"""
Checks to see if RSE exists.
:param rse: Name of the rse.
:param session: The database session in use.
:returns: True if found, otherwise false.
"""
return True if session.query(models.RSE).filter_by(rse=rse, deleted=include_deleted).first() else False
示例10: get_rses_with_attribute_value
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def get_rses_with_attribute_value(key, value, lookup_key, session=None):
"""
Return all RSEs with a certain attribute.
:param key: The key for the attribute.
:param value: The value for the attribute.
:param lookup_key: The value of the this key will be returned.
:param session: The database session in use.
:returns: List of rse dictionaries with the rse_id and lookup_key/value pair
"""
result = REGION.get('av-%s-%s-%s' % (key, value, lookup_key))
if result is NO_VALUE:
rse_list = []
subquery = session.query(models.RSEAttrAssociation.rse_id)\
.filter(models.RSEAttrAssociation.key == key,
models.RSEAttrAssociation.value == value)\
.subquery()
query = session.query(models.RSEAttrAssociation.rse_id,
models.RSEAttrAssociation.key,
models.RSEAttrAssociation.value)\
.join(models.RSE, models.RSE.id == models.RSEAttrAssociation.rse_id)\
.join(subquery, models.RSEAttrAssociation.rse_id == subquery.c.rse_id)\
.filter(models.RSE.deleted == false(),
models.RSEAttrAssociation.key == lookup_key)
for row in query:
rse_list.append({'rse_id': row[0],
'key': row[1],
'value': row[2]})
REGION.set('av-%s-%s-%s' % (key, value, lookup_key), rse_list)
return rse_list
return result
示例11: set_rse_limits
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def set_rse_limits(rse_id, name, value, session=None):
"""
Set RSE limits.
:param rse_id: The RSE id.
:param name: The name of the limit.
:param value: The feature value. Set to -1 to remove the limit.
:param session: The database session in use.
:returns: True if successful, otherwise false.
"""
rse_limit = models.RSELimit(rse_id=rse_id, name=name, value=value)
rse_limit = session.merge(rse_limit)
rse_limit.save(session=session)
return True
示例12: set_rse_transfer_limits
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def set_rse_transfer_limits(rse_id, activity, rse_expression=None, max_transfers=0, transfers=0, waitings=0, volume=0, deadline=1, strategy='fifo', session=None):
"""
Set RSE transfer limits.
:param rse_id: The RSE id.
:param activity: The activity.
:param rse_expression: RSE expression string.
:param max_transfers: Maximum transfers.
:param transfers: Current number of tranfers.
:param waitings: Current number of waitings.
:param volume: Maximum transfer volume in bytes.
:param deadline: Maximum waiting time in hours until a datasets gets released.
:param strategy: Stragey to handle datasets `fifo` or `grouped_fifo`.
:param session: The database session in use.
:returns: True if successful, otherwise false.
"""
try:
rse_tr_limit = models.RSETransferLimit(rse_id=rse_id, activity=activity, rse_expression=rse_expression,
max_transfers=max_transfers, transfers=transfers,
waitings=waitings, volume=volume, strategy=strategy, deadline=deadline)
rse_tr_limit = session.merge(rse_tr_limit)
rowcount = rse_tr_limit.save(session=session)
return rowcount
except IntegrityError as error:
raise exception.RucioException(error.args)
示例13: _list_replicas_for_datasets
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def _list_replicas_for_datasets(dataset_clause, state_clause, rse_clause, updated_after, session):
"""
List file replicas for a list of datasets.
:param session: The database session in use.
"""
replica_query = session.query(models.DataIdentifierAssociation.child_scope,
models.DataIdentifierAssociation.child_name,
models.DataIdentifierAssociation.bytes,
models.DataIdentifierAssociation.md5,
models.DataIdentifierAssociation.adler32,
models.RSEFileAssociation.path,
models.RSEFileAssociation.state,
models.RSE.id,
models.RSE.rse,
models.RSE.rse_type,
models.RSE.volatile).\
with_hint(models.RSEFileAssociation,
text="INDEX_RS_ASC(CONTENTS CONTENTS_PK) INDEX_RS_ASC(REPLICAS REPLICAS_PK) NO_INDEX_FFS(CONTENTS CONTENTS_PK)",
dialect_name='oracle').\
outerjoin(models.RSEFileAssociation,
and_(models.DataIdentifierAssociation.child_scope == models.RSEFileAssociation.scope,
models.DataIdentifierAssociation.child_name == models.RSEFileAssociation.name)).\
join(models.RSE, models.RSE.id == models.RSEFileAssociation.rse_id).\
filter(models.RSE.deleted == false()).\
filter(or_(*dataset_clause)).\
order_by(models.DataIdentifierAssociation.child_scope,
models.DataIdentifierAssociation.child_name)
if state_clause is not None:
replica_query = replica_query.filter(and_(state_clause))
if rse_clause is not None:
replica_query = replica_query.filter(or_(*rse_clause))
if updated_after:
replica_query = replica_query.filter(models.RSEFileAssociation.updated_at >= updated_after)
for replica in replica_query.yield_per(500):
yield replica
示例14: list_rses
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def list_rses(session=None):
"""
List RSEs in the Quarantined Queues.
:param session: The database session in use.
:returns: a list of RSEs.
"""
query = session.query(models.RSE.id).distinct(models.RSE.id).\
filter(models.QuarantinedReplica.rse_id == models.RSE.id).\
filter(models.RSE.deleted == false())
return [rse for (rse,) in query]
示例15: transformations
# 需要导入模块: from sqlalchemy.sql import expression [as 别名]
# 或者: from sqlalchemy.sql.expression import false [as 别名]
def transformations(self, relationship="all"):
"""Get all the transformations of this info.
Return a list of transformations involving this info. ``relationship``
can be "parent" (in which case only transformations where the info is
the ``info_in`` are returned), "child" (in which case only
transformations where the info is the ``info_out`` are returned) or
``all`` (in which case any transformations where the info is the
``info_out`` or the ``info_in`` are returned). The default is ``all``
"""
if relationship not in ["all", "parent", "child"]:
raise ValueError(
"You cannot get transformations of relationship {}".format(relationship)
+ "Relationship can only be parent, child or all."
)
if relationship == "all":
return Transformation.query.filter(
and_(
Transformation.failed == false(),
or_(
Transformation.info_in == self, Transformation.info_out == self
),
)
).all()
if relationship == "parent":
return Transformation.query.filter_by(
info_in_id=self.id, failed=False
).all()
if relationship == "child":
return Transformation.query.filter_by(
info_out_id=self.id, failed=False
).all()