metadata.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:irisett 作者: beebyte 项目源码 文件源码
def delete_metadata(dbcon: DBConnection, object_type: str, object_id: int,
                          keys: Optional[Iterable[str]] = None):
    """Delete metadata for an object.

    If keys is given, only delete the specified keys, otherwise delete all
    metadata for the object.
    """

    async def _run(cur: Cursor) -> None:
        if keys:
            # noinspection PyTypeChecker
            for key in keys:
                q = """delete from object_metadata where object_type=%s and object_id=%s and `key`=%s"""
                q_args = (object_type, object_id, key)  # type: Tuple
                await cur.execute(q, q_args)
        else:
            q = """delete from object_metadata where object_type=%s and object_id=%s"""
            q_args = (object_type, object_id)
            await cur.execute(q, q_args)

    await dbcon.transact(_run)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号