cassandra

How to insert map type into cassandra using cassandra-driver for python

青春壹個敷衍的年華 提交于 2021-02-20 14:58:05
问题 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) This obviously didn't work. I already have a map type column in my column family. How do I go about it? Error: TypeError: not all arguments converted during string formatting 回答1: Use parameter passing form instead of string interpolation: cql = "Insert into table_name (my_key,

How to insert map type into cassandra using cassandra-driver for python

倖福魔咒の 提交于 2021-02-20 14:53:12
问题 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) This obviously didn't work. I already have a map type column in my column family. How do I go about it? Error: TypeError: not all arguments converted during string formatting 回答1: Use parameter passing form instead of string interpolation: cql = "Insert into table_name (my_key,

What to do if Cassandra reports failure but did a partial write?

别来无恙 提交于 2021-02-19 05:08:08
问题 Cassandra does not guarantee atomic behavior so there is a slight chance that one replica fails but other replica do persist the change. Are there any information how to defend against this and what to do in order to heal it if it happens? Does Cassandra heal itself in that regard? [Update] I specially focus on the case where you send a write request to lets say all replica and only one replica fails with a write error. The node failing with the write is still alive and operational. According

Python cassandra-driver OperationTimeOut on every query in Celery task

浪子不回头ぞ 提交于 2021-02-18 22:29:12
问题 I have a problem with every insert query (little query) which is executed in celery tasks asynchronously. In sync mode when i do insert all done great, but when it executed in apply_async() i get this: OperationTimedOut('errors=errors=errors={}, last_host=***.***.*.***, last_host=None, last_host=None',) Traceback: Traceback (most recent call last): File "/var/nfs_www/***/env_v0/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(*args, **kwargs)

Python cassandra-driver OperationTimeOut on every query in Celery task

早过忘川 提交于 2021-02-18 22:28:11
问题 I have a problem with every insert query (little query) which is executed in celery tasks asynchronously. In sync mode when i do insert all done great, but when it executed in apply_async() i get this: OperationTimedOut('errors=errors=errors={}, last_host=***.***.*.***, last_host=None, last_host=None',) Traceback: Traceback (most recent call last): File "/var/nfs_www/***/env_v0/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(*args, **kwargs)

create new record into cassandra DB using java RESTful web service

落花浮王杯 提交于 2021-02-17 07:05:22
问题 I want to use a method that can insert data into my cassandra database , I was able to get data by doing this method public JSONArray getData() { StringBuilder sb = new StringBuilder("SELECT * FROM ").append("user"); String query = sb.toString(); ResultSet rs = session.execute(query); JSONArray users = new JSONArray(); rs.forEach(r -> { JSONObject user = new JSONObject(); users.put( user.put("name", r.getString("name")).put("email", r.getString("email"))); }); return users; } but I dont know

create new record into cassandra DB using java RESTful web service

笑着哭i 提交于 2021-02-17 07:05:12
问题 I want to use a method that can insert data into my cassandra database , I was able to get data by doing this method public JSONArray getData() { StringBuilder sb = new StringBuilder("SELECT * FROM ").append("user"); String query = sb.toString(); ResultSet rs = session.execute(query); JSONArray users = new JSONArray(); rs.forEach(r -> { JSONObject user = new JSONObject(); users.put( user.put("name", r.getString("name")).put("email", r.getString("email"))); }); return users; } but I dont know

'int' object is not iterable : When I try to insert data in Cassandra using Python

大憨熊 提交于 2021-02-16 14:42:28
问题 I am facing some issue while inserting data to a Cassandra Table using Python. Code: session.execute( """ insert into test.student(Student_id) values(%s) """, 56) Error: File "cassandra/cluster.py", line 2239, in cassandra.cluster.Session.execute File "cassandra/cluster.py", line 2279, in cassandra.cluster.Session.execute_async File "cassandra/cluster.py", line 2343, in cassandra.cluster.Session._create_response_future File "cassandra/query.py", line 897, in genexpr File "cassandra/query.py",

How to store 6 digit precision double/float/decimal number in cassandra?

…衆ロ難τιáo~ 提交于 2021-02-11 14:24:15
问题 I am trying to store some strings of a dataframe in cassandra table. I tried with cassandra table columns defining as float/double/decimal. But every type only storing 2 precision , i.e. 8.00005 as stored as 8.00 69.345 as 69.34 , what is wrong with cassandra table? Why it is not holding all precision digits. How fix this issue ? Let me know if needed any more information of the problem. 回答1: This issue seeme to be with the precision settings for cqlsh. The cassandra is storing the values

Problem to load .csv files into Apache Cassandra with Python

旧时模样 提交于 2021-02-11 13:17:33
问题 I'm trying to load a .csv file with Python into Apache Cassandra database. The command "COPY" integrated with session.execute seems don't work. It gives an unexpected indent in correspondance of =',' but...I red something about and I found that the command COPY in this way is not supported. In this script time_test and p are two float variables from cassandra.cluster import Cluster cluster = Cluster() session = cluster.connect('myKEYSPACE') rows = session.execute('COPY table_test (time_test,