【问题标题】:CQLSH COPY ERROR TypeError: 'int' object is not iterableCQLSH COPY ERROR TypeError: 'int' object is not iterable
【发布时间】:2019-04-12 13:56:00
【问题描述】:

我有以下代码试图转储表数据,但出现以下错误 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()

【问题讨论】:

标签: python cassandra datastax cqlsh


【解决方案1】:

COPYcqlsh 推荐——它不是CQL 的一部分,不能通过本机协议客户端执行。您收到此特定错误而不是服务器请求错误,因为您在 Session.executeparameters 位置传递了一致性级别。

您可以使用cqlsh 从脚本中执行此操作,或者查看DS Bulk tool 以获得高性能加载和卸载。

【讨论】:

    猜你喜欢
    • 2020-11-07
    • 2016-02-18
    • 2022-11-02
    • 2018-06-29
    • 2016-01-09
    • 2018-12-10
    • 1970-01-01
    • 2022-12-15
    • 2021-08-08
    相关资源
    最近更新 更多