<Error from server: code=2000 [Syntax error in CQL query] message="line 1:57 no viable alternative at input ';' (...,vendedor, total) VALUES ([;])">
<Error from server: code=2000 [Syntax error in CQL query] message="line 1:57 no viable alternative at input ';' (...,vendedor, total) VALUES ([;])">
我正在尝试通过 python 将 .csv 文件中的数据插入到 cassandra 中。我的代码正在读取此列表并已连接到 Cassandra,但在插入时出现错误:cassandra.protocol.SyntaxException:
实际上,经过一整天的尝试,我找到了一种使用 Pandas 插入 .csv 文件中所有数据的方法:使用 pd.Dataframe 和逐项插入的“for”处理,如下:
tabela = pd.DataFrame(lista_arq2)
tabela.columns = ['nota_fiscal', 'vendedor', 'total']
print(tabela)
for i, j in tabela.iterrows():
item = "{},'{}',{}".format(j.nota_fiscal, j.vendedor,j.total)
query1 = "INSERT INTO vendas (codigo,nota_fiscal,vendedor, total) VALUES (uuid(),"+ item + ");"
session.execute(query1)
这样数据就完美地包含在 Cassandra 中了。
我正在尝试通过 python 将 .csv 文件中的数据插入到 cassandra 中。我的代码正在读取此列表并已连接到 Cassandra,但在插入时出现错误:cassandra.protocol.SyntaxException: 实际上,经过一整天的尝试,我找到了一种使用 Pandas 插入 .csv 文件中所有数据的方法:使用 pd.Dataframe 和逐项插入的“for”处理,如下: 这样数据就完美地包含在 Cassandra 中了。tabela = pd.DataFrame(lista_arq2)
tabela.columns = ['nota_fiscal', 'vendedor', 'total']
print(tabela)
for i, j in tabela.iterrows():
item = "{},'{}',{}".format(j.nota_fiscal, j.vendedor,j.total)
query1 = "INSERT INTO vendas (codigo,nota_fiscal,vendedor, total) VALUES (uuid(),"+ item + ");"
session.execute(query1)