Example #1
0
def get_quads(subject, predicate, object):
    client, db = init_db_cayley()
    quads = get_quads_collection(db)
    result = quads.find_one({SUBJECT: subject, PREDICATE: predicate,
                             OBJECT: object})
    close_client(client)
    return result
Example #2
0
def get_quads(subject, predicate, object):
    client, db = init_db_cayley()
    quads = get_quads_collection(db)
    result = quads.find_one({
        SUBJECT: subject,
        PREDICATE: predicate,
        OBJECT: object
    })
    close_client(client)
    return result
Example #3
0
def update_quads(subject, predicate, object, **kwargs):
    client, db = init_db_cayley()
    quads = get_quads_collection(db)

    attr_dict = {}
    if LABEL in kwargs:
        attr_dict[LABEL] = kwargs[LABEL]
    if URLS in kwargs:
        attr_dict[URLS] = kwargs[URLS]
    if TIMESTAMP in kwargs:
        attr_dict[TIMESTAMP] = kwargs[TIMESTAMP]

    updated = False
    if attr_dict:
        result = quads.update({SUBJECT: subject,
                               PREDICATE: predicate,
                               OBJECT: object},
                              {'$set': attr_dict})
        updated = result['updatedExisting']

    close_client(client)
    return updated
Example #4
0
def update_quads(subject, predicate, object, **kwargs):
    client, db = init_db_cayley()
    quads = get_quads_collection(db)

    attr_dict = {}
    if LABEL in kwargs:
        attr_dict[LABEL] = kwargs[LABEL]
    if URLS in kwargs:
        attr_dict[URLS] = kwargs[URLS]
    if TIMESTAMP in kwargs:
        attr_dict[TIMESTAMP] = kwargs[TIMESTAMP]

    updated = False
    if attr_dict:
        result = quads.update(
            {
                SUBJECT: subject,
                PREDICATE: predicate,
                OBJECT: object
            }, {'$set': attr_dict})
        updated = result['updatedExisting']

    close_client(client)
    return updated
Example #5
0
def get_nodes_count():
    client, db = init_db_cayley()
    nodes = get_nodes_collection(db)
    count = nodes.find().count()
    close_client(client)
    return count
Example #6
0
def get_quads_count():
    client, db = init_db_cayley()
    quads = get_quads_collection(db)
    count = quads.find().count()
    close_client(client)
    return count
Example #7
0
def get_nodes_count():
    client, db = init_db_cayley()
    nodes = get_nodes_collection(db)
    count = nodes.find().count()
    close_client(client)
    return count
Example #8
0
def get_quads_count():
    client, db = init_db_cayley()
    quads = get_quads_collection(db)
    count = quads.find().count()
    close_client(client)
    return count