import pandas as pd
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
from cassandra.query import dict_factory
auth_provider = PlainTextAuthProvider(username=CASSANDRA_USER, password=CASSANDRA_PASS)
cluster = Cluster(contact_points=[CASSANDRA_HOST], port=CASSANDRA_PORT, auth_provider=auth_provider)
session = cluster.connect(CASSANDRA_DB)
session.row_factory = dict_factory
sql_query = "SELECT * FROM {}.{};".format(CASSANDRA_DB, CASSANDRA_TABLE)
df = pd.DataFrame()
for row in session.execute(sql_query):
df = df.append(pd.DataFrame(row, index=[0]))
df = df.reset_index(drop=True).fillna(pd.np.nan)
Reading 1000 rows takes 1 minute, and I have a "bit more"... If I run the same query eg. in DBeaver, I get the whole results (~40k rows) within a minute.
If I use the official faster deserialization method:
from cassandra.protocol import NumpyProtocolHandler, LazyProtocolHandler
from cassandra.query import tuple_factory
session.client_protocol_handler = LazyProtocolHandler
session.row_factory = tuple_factory
session.client_protocol_handler = NumpyProtocolHandler
NoHostAvailable: ('Unable to complete the operation against any hosts', {<Host: my_host>: AttributeError("'NoneType' object has no attribute 'encode_message'",), <Host: my_host>: AttributeError("'NoneType' object has no attribute 'encode_message'",), <Host: my_host>: AttributeError("'NoneType' object has no attribute 'encode_message'",)})
What do I wrong?
Thank you!!!
WARNING:cassandra.protocol:Server warning: Read 18814 live rows and 99999 tombstone cells for query SELECT * FROM my_table WHERE datetime <= my_ts_uuid LIMIT 18814 (see tombstone_warn_threshold)
WARNING:cassandra.protocol:Server warning: Read 18815 live rows and 100001 tombstone cells for query SELECT * FROM my_table WHERE datetime <= my_ts_uuid LIMIT 18816 (see tombstone_warn_threshold)
ReadFailure: Error from server: code=1300 [Replica(s) failed to execute read] message="Operation failed - received 0 responses and 1 failures" info={'failures': 1, 'required_responses': 1, 'consistency': 'LOCAL_ONE', 'received_responses': 0}