How to insert map type in cassandra using cassandra driver for python

Since cassandra supports map type. I want to insert a python dict into cassandra. I tried this:

cql = "Insert into table_name (my_key, name, my_dict) values (%s, %s, %s)" % (my_key, name, my_dict) session.execute(cql) 

It obviously didn't work.

I already have a map type column in my column family. How can I do it?

Error: TypeError: not all arguments converted during string formatting

+5
source share
1 answer

Use the transfer option instead of string interpolation:

 cql = "Insert into table_name (my_key, name, my_dict) values (%s, %s, %s)" session.execute(cql, (my_key, name, my_dict)) 
+3
source

Source: https://habr.com/ru/post/1203991/


All Articles