validation_script.py 文件源码

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

项目:benzoin 作者: mpilar 项目源码 文件源码
def validate_all_collections():
    """ Connecto to mongo and run db.collection.validate() on everything """
    retry_count = 0
    try:
        client = pymongo.MongoClient("localhost", 27017, maxPoolSize=50)
    except Exception as exc:
        if retry_count > 20:
            raise Exception("Retries exceeded") from exc
        retry_count += 1
        sleep(6)
    for db in (client[name] for name in
               client.database_names()
               if name != "local"):
        for collection in db.collection_names(include_system_collections=False):
            if db.validate_collection(collection, scandata=True, full=True)['errors']:
                raise ValidationFailed("Collection failed to validate", collection)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号