0
votes

How can I populate data dynamically with LIKE queries

I tried this:

q1 = sesi.execute("SELECT * FROM document WHERE judul LIKE '%s' ", "cluster" )

But I get the following error:

Traceback (most recent call last): File "", line 1, in File "/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/cluster.py", line 2012, in execute

return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state).result()

File "/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/cluster.py", line 2049, in execute_async

future = self._create_response_future(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state)

File "/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/cluster.py", line 2109, in _create_response_future query_string = bind_params(query_string, parameters, self.encoder) File "/var/www/app_arsip/flask/local/lib/python2.7/site-packages/cassandra/query.py", line 826, in bind_params return query % tuple(encoder.cql_encode_all_types(v) for v in params)

TypeError: not all arguments converted during string formatting

I hope someone can help me

Thank you

1

1 Answers

1
votes

Change your query, remove single quote and enclose your parameter with []

q1 = sesi.execute("SELECT * FROM document WHERE judul LIKE %s", ["%cluster%"] )