How to use the tiledb.KV function in tiledb

To help you get started, we’ve selected a few tiledb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TileDB-Inc / TileDB-Py / examples / kv.py View on Github external
def iter_kv():
    with tiledb.KV(array_name, mode='r') as A:
        for p in A:
            print("key: '%s', value: '%s'" % (p[0], p[1]))
github TileDB-Inc / TileDB-Py / examples / libtiledb / tiledb_kv.py View on Github external
def main():
    # Create TileDB context
    ctx = tiledb.Ctx()

    # KV objects are limited to storing string keys/values for the time being
    a1 = tiledb.Attr(ctx, "value", compressor=("gzip", -1), dtype=bytes)
    kv = tiledb.KV(ctx, "my_kv", attrs=(a1,))

    # Dump the KV schema
    kv.dump()

    # Update the KV with some key-value pairs
    vals = {"key1": "a", "key2": "bb", "key3": "dddd"}
    print("Updating KV with values: {!r}\n".format(vals))
    kv.update(vals)

    # Get kv item
    print("KV value for 'key3': {}\n".format(kv['key3']))

    try:
        kv["don't exist"]
    except KeyError:
        print("KeyError was raised for key 'don't exist'\n")
github TileDB-Inc / TileDB-Py / examples / kv.py View on Github external
def read_array():
    # Open the array and read from it.
    with tiledb.KV(array_name, mode='r') as A:
        print("key_1: %s" % A["key_1"])
        print("key_2: %s" % A["key_2"])
        print("key_3: %s" % A["key_3"])
github TileDB-Inc / TileDB-Py / examples / quickstart_kv.py View on Github external
def read_array():
    # Open the array and read from it.
    with tiledb.KV(kv_name, mode='r') as A:
        print("key_1: %s" % A["key_1"])
        print("key_2: %s" % A["key_2"])
        print("key_3: %s" % A["key_3"])
github TileDB-Inc / TileDB-Py / examples / quickstart_kv.py View on Github external
def create_array():
    # The KV array will have a single attribute "a" storing a string.
    schema = tiledb.KVSchema(attrs=[tiledb.Attr(name="a", dtype=bytes)])

    # Create the (empty) array on disk.
    tiledb.KV.create(kv_name, schema)
github TileDB-Inc / TileDB-Py / examples / kv.py View on Github external
def create_array():
    # Create a KV with a single attribute.
    # Note: KV arrays with multiple attributes or non-string-valued attributes
    # are not currently supported in Python.
    schema = tiledb.KVSchema(attrs=[tiledb.Attr(name="a1", dtype=bytes)])

    # Create the (empty) array on disk.
    tiledb.KV.create(array_name, schema)
github TileDB-Inc / TileDB-Py / examples / kv.py View on Github external
def write_array():
    # Open the array and write to it.
    # We can optionally set the number of items to buffer before a flush.
    with tiledb.KV(array_name, mode='w') as A:
        A["key_1"] = "1"
        A["key_2"] = "2"
        A["key_3"] = "3"
        A.flush()