我正在尝试通过使用json模块从json检索json的列,然后使用prepared语句将其插入cassandra中来将json文件插入cassandra表中。文件恰好是2778ko,我不知道如何插入它。请帮忙!!!
query = """
INSERT INTO profile9 (id,profilelegacy,profilealternative,aboutlegacy,skills,recommendations,accomplishments,peoplealsoviewed,volunteerExperience,profile)
VALUES (?,?,?,?,?,?,?,?,?,?);
"""
insert_user = session.prepare(query)
batch = BatchStatement(consistency_level=ConsistencyLevel.ONE)
batch.add(insert_user, (idd, profileLegacy, profilealternative, aboutlegacy, skills,
recommendations, accomplishments, peopleAlsoviewed, volunteerExperience, profile,))
log = logging.getLogger()
log.info('Batch Insert Completed')
session.execute(batch)
我收到此错误
line 64, in parsing
session.execute(batch)
File "C:\Python\Python37\lib\site-packages\cassandra\cluster.py", line 2240, in execute
timeout, execution_profile, paging_state, host).result()
File "C:\Python\Python37\lib\site-packages\cassandra\cluster.py", line 4198, in result
raise self._final_exception
cassandra.InvalidRequest: Error from server: code=2200 [Invalid query] message="Batch too large"
答案 0 :(得分:2)
这里没有理由使用批处理,只会使事情变慢,并施加大小限制。只需将其更改为:
# only prepare this once
prepared = session.prepare(query)
...
session.execute(prepared.bind((idd, profileLegacy, profilealternative, aboutlegacy, skills,
recommendations, accomplishments, peopleAlsoviewed, volunteerExperience, profile,)))