0

iam new to cassandra, i want to do get query using cassandra python client? iam not able to escape special characters.can anyone help Below is the query which iam trying, but getting syntax error

SELECT pmid FROM chemical WHERE mentions=$$ N,N'-((1Z,3Z)-1,4-bis(4-methoxyphenyl)buta-1,3-diene-2,3-diyl)diformamide $$ AND pmid=31134000 ALLOW FILTERING;

it is giving me error Error from server: code=2000 [Syntax error in CQL query] message="line 1:118 mismatched input '-' expecting ')' (...,source) VALUES ('be75372a-c311-11e9-ac2c-0a0df85af938','N,N'[-]...)"

  • I don't see any special characters in your string – Kostas Charitidis Aug 20 '19 at 06:24
  • iam getting syntax error,when iam doing above query @KostasCharitidis cassandra.protocol.SyntaxException: – Mohammed Sameer Aug 20 '19 at 06:28
  • Can you provide more of the python code that you are using?. With the information provided, you may want to use a prepared statement, there are multiple examples in https://docs.datastax.com/en/developer/python-driver/3.18/api/cassandra/query/ . Also, please, avoid the use of `ALLOW FILTERING` (https://www.datastax.com/dev/blog/allow-filtering-explained-2) – Carlos Monroy Nieblas Aug 20 '19 at 06:30
  • I haven't used cassandra, but are your sure that this is the correct syntax? Try to run your query outside python to check if runs correctly and then pass it inside your code. – Kostas Charitidis Aug 20 '19 at 06:34

1 Answers1

0

Based on the Syntax Provided as i see there is a Single quotes missing in your Query .

Suggestion Note to use ALLOW FILTERING as it will Scan your Table which will be a performance issue.

Ahsan
  • 16