小编Cha*_*dan的帖子

无法使用 Python 导出 Cassandra 表

我正在尝试使用 Python 将 Cassandra 表导出为 CSV 格式。但我做不到。但是,我可以从 Python 执行“select”语句。我使用了以下代码:

from cassandra.cluster import Cluster
cluster = Cluster ()
session = cluster.connect('chandan') ### 'chandan' is the name of the   keyspace
## name of the table is 'emp'
session.execute(""" copy emp (id,name) to 'E:\HANA\emp.csv' with HEADER = true """ )
print "Exported to the CSV file"
Run Code Online (Sandbox Code Playgroud)

请在这方面帮助我。

python export cql cassandra cqlsh

2
推荐指数
1
解决办法
1544
查看次数

如何将列表转换为1项字典列表

我有一个清单

a=[('policy', 871),
 ('insurance', 382),
 ('life', 357),
 ('request', 270),
 ('call', 260)]
Run Code Online (Sandbox Code Playgroud)

现在,我想将其转换为一个项目的列表dict:

[{'call': 260},{'insurance': 382},{'life': 357}, {'policy': 871}, {'request': 270}]
Run Code Online (Sandbox Code Playgroud)

python list

-3
推荐指数
1
解决办法
104
查看次数

标签 统计

python ×2

cassandra ×1

cql ×1

cqlsh ×1

export ×1

list ×1