I am new to cassandra and trying to insert in Cassandra keyspace using Python. I have a table mytablecassandra created with cql:
cqlsh:mykeyspace>>CREATE TABLE mytablecassandra(user text PRIMARY KEY, friendlist list<text>);
auser = 'ABC'
afriend = ['DEF','GHI','JKL']
from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect('mykeyspace')
CQLString = """INSERT INTO mytablecassandra(user,friendlist) VALUES (auser, afriend)"""
ErrorMessage code=2000 [Syntax error in CQL query] no viable
alternative at input ')'
Your strings don't get expanded in place that way, nor is it really the recommended way (that way lies SQL injection attacks often). Instead you should make your query string have place holders for the values like
CQLString = "INSERT INTO mytablecassandra (user, friendlist) VALUES (%s,%s)"
then execute it and pass the values in like