My query:
SELECT *
FROM employee.emp_details
WHERE id = 7
This is my code
from cassandra.cluster import Cluster
HOST = ['10.107.2.123']
PORT = '9042'
cluster = Cluster(HOST, PORT)
session = cluster.connect()
val = 'FROM'
rows = session.execute('''SELECT * %s employee.emp_details WHERE id = %s''', (val, 7))
This is the error that I am getting:
Traceback (most recent call last):
File "/home/sachhya/Documents/Example/ex.py", line 9, in
rows = session.execute('''SELECT * %s employee.emp_details WHERE id = %s''', (val, 7))
File "/usr/local/lib/python3.6/dist-packages/cassandra/cluster.py", line 2134, in execute
return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state).result()
File "/usr/local/lib/python3.6/dist-packages/cassandra/cluster.py", line 4026, in result
raise self._final_exception
cassandra.protocol.SyntaxException:
I believe that my query string is something made like that after parameter bind. SELECT * 'FROM' employee.emp_details WHERE id = 7
Please help I need to use 'val' variable to bind in my query string.
'FROM'
? – Azat Ibrakov