本文整理汇总了Python中pyramid_sqlalchemy.Session.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Session.execute方法的具体用法?Python Session.execute怎么用?Python Session.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid_sqlalchemy.Session
的用法示例。
在下文中一共展示了Session.execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collection_timestamp
# 需要导入模块: from pyramid_sqlalchemy import Session [as 别名]
# 或者: from pyramid_sqlalchemy.Session import execute [as 别名]
def collection_timestamp(self, collection_id, parent_id, auth=None):
"""Get the highest timestamp of every objects in this `collection_id` for
this `parent_id`.
.. note::
This should take deleted objects into account.
:param str collection_id: the collection id.
:param str parent_id: the collection parent.
:returns: the latest timestamp of the collection.
:rtype: int
"""
tb = Timestamps.__table__
qry = select([label('last_modified', func.max(tb.c.last_modified))]).where(and_(
tb.c.parent_id == parent_id,
tb.c.collection_id == collection_id))
last_modified, = Session.execute(qry).fetchone()
if last_modified is None:
last_modified = datetime.datetime.utcnow()
with transaction.manager:
Session.add(Timestamps(parent_id=parent_id, collection_id=collection_id,
last_modified=last_modified))
return last_modified.replace(tzinfo=datetime.timezone.utc).timestamp()
示例2: purge_deleted
# 需要导入模块: from pyramid_sqlalchemy import Session [as 别名]
# 或者: from pyramid_sqlalchemy.Session import execute [as 别名]
def purge_deleted(self, collection_id, parent_id, before=None,
id_field=DEFAULT_ID_FIELD,
modified_field=DEFAULT_MODIFIED_FIELD,
auth=None):
"""Delete all deleted object tombstones in this `collection_id`
for this `parent_id`.
:param str collection_id: the collection id.
:param str parent_id: the collection parent.
:param int before: Optionnal timestamp to limit deletion (exclusive)
:returns: The number of deleted objects.
:rtype: int
"""
tb = Deleted.__table__
rst = Session.execute(tb.delete().where(and_(tb.c.parent_id == parent_id, tb.c.collection_id == collection_id)))
return rst
示例3: set_config
# 需要导入模块: from pyramid_sqlalchemy import Session [as 别名]
# 或者: from pyramid_sqlalchemy.Session import execute [as 别名]
def set_config(user):
stmt = select([func.set_config(cast('my.city_id', String), cast(user.city.id, String), True)])
Session.execute(stmt)