TileDB Python API

0.36.1 · active · verified Thu Apr 16

TileDB-Py is the official Python interface to the TileDB Storage Engine, an efficient multi-dimensional array management system. It provides a Pythonic API for storing and accessing dense and sparse array data, featuring fast updates, reads, excellent compression, and efficient parallel I/O with high scalability. The library is actively maintained, with version 0.36.1 released on February 25, 2026, and regular updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a TileDB dense array, write NumPy data to it, and read a slice of the data. The array is stored locally on disk.

import tiledb
import numpy as np
import os

# Define array URI
array_uri = "my_dense_array"

# Clean up previous array if it exists
if os.path.exists(array_uri):
    tiledb.remove(array_uri)

# 1. Create a dense array schema
dom = tiledb.Domain(
    tiledb.Dim(name="rows", domain=(1, 4), tile=4, dtype=np.int32),
    tiledb.Dim(name="cols", domain=(1, 4), tile=4, dtype=np.int32)
)
attr = tiledb.Attr(name="data", dtype=np.int32)
schema = tiledb.ArraySchema(domain=dom, attrs=[attr], sparse=False)

# 2. Create the array
tiledb.DenseArray.create(array_uri, schema)

# 3. Write data to the array
with tiledb.DenseArray(array_uri, mode="w") as A:
    data = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])
    A[:] = data

# 4. Read data from the array (slice)
with tiledb.DenseArray(array_uri, mode="r") as A:
    # Read a slice (e.g., rows 1-2, cols 2-3)
    subset = A[1:3, 2:4]
    print("Read subset:")
    print(subset)

# Clean up
tiledb.remove(array_uri)

view raw JSON →