Python pymongo.errors 模块,DocumentTooLarge() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用pymongo.errors.DocumentTooLarge()

项目:tweegraph    作者:PGryllos    | 项目源码 | 文件源码
def store_timeline(db_name, user_id, timeline):
    """stores the timeline as a list of json formated statuses in
    db -> db_name[user_id] under the key 'content'

    db_name  : name of the database
    user_id  : twitter id of user
    timeline : user timeline entity as returned by the twitter api
    """
    db_client = MongoClient()
    timeline = [status._json for status in timeline]

    if timeline:
        while True:
            try:
                db_client[db_name][str(user_id)].insert_one(
                        {'_id': user_id, 'content': timeline})
                break
            except DocumentTooLargeError as e:
                timeline = timeline[:-1]
            except WriteError as e:
                timeline = timeline[:-1]
项目:mongodb-monitoring    作者:jruaux    | 项目源码 | 文件源码
def _raise_document_too_large(operation, doc_size, max_size):
    """Internal helper for raising DocumentTooLarge."""
    if operation == "insert":
        raise DocumentTooLarge("BSON document too large (%d bytes)"
                               " - the connected server supports"
                               " BSON document sizes up to %d"
                               " bytes." % (doc_size, max_size))
    else:
        # There's nothing intelligent we can say
        # about size for update and remove
        raise DocumentTooLarge("command document too large")
项目:covar_me_app    作者:CovarMe    | 项目源码 | 文件源码
def _raise_document_too_large(operation, doc_size, max_size):
    """Internal helper for raising DocumentTooLarge."""
    if operation == "insert":
        raise DocumentTooLarge("BSON document too large (%d bytes)"
                               " - the connected server supports"
                               " BSON document sizes up to %d"
                               " bytes." % (doc_size, max_size))
    else:
        # There's nothing intelligent we can say
        # about size for update and remove
        raise DocumentTooLarge("command document too large")
项目:kekescan    作者:xiaoxiaoleo    | 项目源码 | 文件源码
def _raise_document_too_large(operation, doc_size, max_size):
    """Internal helper for raising DocumentTooLarge."""
    if operation == "insert":
        raise DocumentTooLarge("BSON document too large (%d bytes)"
                               " - the connected server supports"
                               " BSON document sizes up to %d"
                               " bytes." % (doc_size, max_size))
    else:
        # There's nothing intelligent we can say
        # about size for update and remove
        raise DocumentTooLarge("command document too large")
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def _raise_document_too_large(operation, doc_size, max_size):
    """Internal helper for raising DocumentTooLarge."""
    if operation == "insert":
        raise DocumentTooLarge("BSON document too large (%d bytes)"
                               " - the connected server supports"
                               " BSON document sizes up to %d"
                               " bytes." % (doc_size, max_size))
    else:
        # There's nothing intelligent we can say
        # about size for update and remove
        raise DocumentTooLarge("command document too large")
项目:Data-visualization    作者:insta-code1    | 项目源码 | 文件源码
def _raise_document_too_large(operation, doc_size, max_size):
    """Internal helper for raising DocumentTooLarge."""
    if operation == "insert":
        raise DocumentTooLarge("BSON document too large (%d bytes)"
                               " - the connected server supports"
                               " BSON document sizes up to %d"
                               " bytes." % (doc_size, max_size))
    else:
        # There's nothing intelligent we can say
        # about size for update and remove
        raise DocumentTooLarge("command document too large")
项目:hudl-bugbounty    作者:lewislabs    | 项目源码 | 文件源码
def _raise_document_too_large(operation, doc_size, max_size):
    """Internal helper for raising DocumentTooLarge."""
    if operation == "insert":
        raise DocumentTooLarge("BSON document too large (%d bytes)"
                               " - the connected server supports"
                               " BSON document sizes up to %d"
                               " bytes." % (doc_size, max_size))
    else:
        # There's nothing intelligent we can say
        # about size for update and remove
        raise DocumentTooLarge("command document too large")
项目:hudl-bugbounty    作者:lewislabs    | 项目源码 | 文件源码
def _raise_document_too_large(operation, doc_size, max_size):
    """Internal helper for raising DocumentTooLarge."""
    if operation == "insert":
        raise DocumentTooLarge("BSON document too large (%d bytes)"
                               " - the connected server supports"
                               " BSON document sizes up to %d"
                               " bytes." % (doc_size, max_size))
    else:
        # There's nothing intelligent we can say
        # about size for update and remove
        raise DocumentTooLarge("command document too large")