Search code examples
cassandracqlcql3cqlsh

How to upload/insert binary (blob) data to Cassandra 2.2 database (using DevCenter or cqlsh)


Hi I'm new to Cassandra/CQL but have SQL/relational database experience.

I have a very simple key space and table setup for testing purposes and need to add some very basic data - some of which is in BLOB format.

CREATE TABLE file_share (
   key varchar,
   content_type varchar,
   client_id varchar,
   org_id varchar,
   user_id varchar,
   value blob,
   internal_key uuid,
   PRIMARY KEY (client_id, org_id, user_id, key)
);

The trouble for me right now is: How can i (using a script INSERT statement or the like) put some dummy data - specifically in the blob itself so that I can use it for testing? Is there a way to upload a file? If so, how? If not, is there a better way to get binary data as blob? I've been trying to find a list of blob handling functions for CQL but can't find anything so far. Thanks


Solution

  • If this is just for testing you can use the following syntax:

    INSERT INTO file_share (client_id, org_id, user_id, key, value)
           VALUES ('A', 'B', 'C' , 'D', 0xabcd);
    

    I don't know of any way to input file data to a blob using cqlsh.