Question

My goal is populate cassandra with some data using a script. I'm looking for something like:

CREATE TABLE simplex.songs (id uuid PRIMARY KEY, img blob);
INSERT INTO simplex.songs (id, img) VALUES(2cc9ccb7-6221-4ccb-8387-f22b6a1b354d, hexAsBlob({hex representation of my image}));

or

INSERT INTO simplex.songs (id, img) VALUES(2cc9ccb7-6221-4ccb-8387-f22b6a1b354d, readFromFile({ image file name}));

Is it possible? I know hexAsBlob & readFromFile do not exist, but maybe there is something similar? And because it's script I cannot use BoundStatement

Was it helpful?

Solution

You can use an hexadecimal literal in CQL.

For example:

INSERT INTO simplex.songs (id, img) 
VALUES (2cc9ccb7-6221-4ccb-8387-f22b6a1b354d, 0xaa001112);

From CQL3 documentation: A blob constant is an hexadecimal number defined by 0xX+ where hex is an hexadecimal character, e.g. [0-9a-fA-F].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top