BLOB type (Python)

Use the blob type for binary data.

Although you can store binary-encoded vector data in a blob column, you cannot create a vector index or perform a vector search on the column. Instead, use the vector type to store vector data.

Due to a known issue with filtering on blob, DataStax does not recommend using blob in primary keys.

You can insert binary data to a blob column as a Base64-encoded string with $binary or as a bytes value.

The Python client returns binary data received from the Data API as a bytes value, even if it was inserted as a Base64-encoded string.

from astrapy import DataAPIClient

# Get an existing table
client = DataAPIClient()
database = client.get_database(
    "API_ENDPOINT", token="APPLICATION_TOKEN"
)
table = database.get_table("TABLE_NAME")

# Insert binary values
result = table.insert_one(
    {
        "example_blob": b"=\xfb\xe7m>\xe9x\xd5?I\xfb\xe7",
        "another_example_blob": {"$binary": "PfvnbT7peNU/Sfvn"},
        "title": "Example",
    }
)

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM