pandas ingestion.
cassandra, row_factory:
from cassandra.query import (
dict_factory,
SimpleStatement
)
from cassandra.cluster import (
Cluster,
ExecutionProfile,
EXEC_PROFILE_DEFAULT
)
profile = ExecutionProfile(
row_factory=dict_factory
)
hosts = ["127.0.0.1"]
port = 9042
cluster = Cluster(
hosts,
port=port,
execution_profiles={EXEC_PROFILE_DEFAULT: profile}
)
:
src_keyspace = "your_keyspace"
src_tbl = "your_table"
N_ROWS = 100
with cluster.connect(src_keyspace) as cass_session:
res = cass_session.execute(
SimpleStatement("SELECT * FROM {} LIMIT {}".format(src_tbl,
N_ROWS))
)
OrderedMapSerializedKey dict:
rows_as_dict = [
{ key: (val if not isinstance(val, OrderedMapSerializedKey)
else dict(val)) for key, val in row.items() }
for row in res.current_rows
]
pandas.DataFrame.from_dict