python - CQLSH COPY ERROR TypeError: 'int' object is not iterable
问题描述
我有下面的代码试图转储表数据,但出现错误 TypeError: 'int' object is not iterable。
import argparse
import sys
import itertools
import codecs
import uuid
import os
try:
import cassandra
import cassandra.concurrent
except ImportError:
sys.exit('Python Cassandra driver not installed. You might try \"pip install cassandra-driver\".')
from cassandra.cluster import Cluster, ResultSet
from cassandra.policies import DCAwareRoundRobinPolicy
from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import ConsistencyLevel
datafile = "/Users/username/adf.csv"
if os.path.exists(datafile):
os.remove(datafile)
def dumptableascsv():
auth_provider = PlainTextAuthProvider(username='cassandra', password='cassandra')
cluster = Cluster(['127.0.0.1'],
load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='Cassandra'),
port=9042, auth_provider=auth_provider)
session = cluster.connect('qualys_ioc')
session.execute("COPY qualys_ioc.agent_delta_fragment(agent_id , delta_id , fragment_id, boolean ,created_on) TO "
"'/Users/username/adf.csv' WITH HEADER = true ;", ConsistencyLevel.QUORUM)
dumptableascsv()
解决方案
COPY
是一个cqlsh
推荐 - 它不是 的一部分CQL
,并且不能通过本机协议客户端执行。您收到此特定错误而不是服务器请求错误,因为您parameters
在Session.execute
.
您可以使用cqlsh
脚本来执行此操作,或者查看DS Bulk 工具以实现高性能加载和卸载。
推荐阅读
- java - Android TextView 的文本可以在 onCreate() 方法之外设置吗?
- hyperledger-fabric - 在 HyperLedger 中使用 OAuth 2.0 和多用户进行身份验证
- java - 如何使用具有最小值和最大值的 math.random?
- javascript - 如何使用 Jquery 从动态表中获取值?
- django - Django Rest Framework:RecursionError at /profile/ 调用 Python 对象时超出最大递归深度
- r - 在自定义函数中使用 xyplot 和 R 中的面板函数
- swift - 如何为增加其宽度的渐变层设置动画?
- linux - 未定义对“clock_gettime”的引用,修改makefile?
- java - 如何在后台运行秒表?
- sql-server - SQL 服务器 | 找出计数和类别