2

I have installed Cassandra 2.2.12 on my window machine locally. I have exported database from live server in a '.sql' file using 'razorsql' GUI tool. I don't have server access for live, only have database access. When i am trying ti import '.sql' file using 'razorsql' to local cassandra setup, its giving me error (Invalid STRING constant '8ca25030-89ab-11e7-addb-70a0656e5127' for "id" of type timeuuid). Even i tried using COPY FROM command, its returning same error. Please find attached screen-shot for more detail of error. enter image description here

Could anybody please help?

Horia
  • 2,942
  • 7
  • 14
M.Bains
  • 395
  • 1
  • 2
  • 14
  • Your file contains single quotes around the id (something similar with `INSERT INTO test.test(id, value) VALUES ('8ca25030-89ab-11e7-addb-70a0656e5127', 'v01');` )? If so, remove the single quotes from the id value (`INSERT INTO test.test(id, value) VALUES (8ca25030-89ab-11e7-addb-70a0656e5127, 'v01');`) – Horia Jul 10 '18 at 05:51
  • Thanks for reply @Horia. But i have exported the entire database and single quotes are on every table's id column in exported file. So please suggest me how can i remove them (single quotes) from backup file. – M.Bains Jul 10 '18 at 06:38

2 Answers2

3

You should not put any quotes, because then it gets interpreted as a string instead of UUID - hence the error message.

See also: Inserting a hard-coded UUID via CQLsh (Cassandra)

Andrea Nagy
  • 1,201
  • 9
  • 21
  • Thanks for reply @andrea. I have not hard-coded the values, actually they are exported to a file via "razorsql" tool. There are number of tables and records in database. So please suggest me how can i remove them (single quotes) from backup file. Or is there any other best method to take database export/import again. I don't have access to live server UI/login. – M.Bains Jul 10 '18 at 08:53
  • I am not familiar with RazorSql, if I have to I use DBeaver for Cassandra - although as it is not a dedicated Cassandra client and has lots of limitations. I think it also stands for RazorSql, which is basically the cause of your problem. What I would do in your case: 1.) check if a single insert works without the quotes 2.) if yes, edit your csv to remove the quotes. You can write a script, which does that, on Linux you can do something like: sed 's/./ /X' export.csv where X is the position of the quote (e.g. 2 if it is in the 2nd char) or use notepad++ macro, if the csv is not too long. – Andrea Nagy Jul 10 '18 at 09:07
  • I am planning to create some script which will read the file and remove quotes from id (primary key) field for all tables. – M.Bains Jul 11 '18 at 08:46
  • Another way to do it is to export data (using RazorSQL) as csv. In csv it does not export using single quotes. Is just the data, separated with comma and new line. Then you could safely use copy command in cqlsh. – Horia Jul 12 '18 at 23:50
0

I think you have two solutions:

  1. edit your export file and remove the single quotes from the inserts.
  2. rerun the export and export the data as csv and run the copy command in cqlsh. In this case, the csv file will not have quotes.
Horia
  • 2,942
  • 7
  • 14