cassandra.protocol.SyntaxException: <来自服务器的错误:code=2000 [CQL 查询中的语法错误] message="line 1:137 输入时没有可行的替代方案

cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 1:137 no viable alternative at input

我正在尝试将一个 zip 文件插入到 cassandra db 的 blob 存储中。 在创建 table 列

时键入 workflowid str 和 savepath blob

尝试:

bin_data = open('4e9b-9c08-e3cafafd871b-20211129034556.zip', 'rb').read()
print(type(bin_data))
#hex_data = codecs.encode(bin_data, "hex_codec")
#print(type(hex_data))
auth_provider = PlainTextAuthProvider(username = username , password = password)
cluster = Cluster(contact_points = [ip], port=1234, auth_provider = auth_provider)
session = cluster.connect("keyspace")
session.row_factory = dict_factory
resultpath = bin_data
workflowid = "d6fe8ea4-fffd"
query = "insert into tablename(resultpath, workflowid) VALUES({resultpath}, '{workflowid}');".format(resultpath, workflowid)
rslt = session.execute(query, timeout=None)
df = pd.DataFrame(rslt)
print(df)

except Exception as E:
    print("Error: ", str(E))

BLOB 中的一些数据似乎没有被正确转义。尝试使用准备好的语句,而不是:

query = "insert into tablename(resultpath, workflowid) VALUES(?,?);"
pStatement = session.prepare(query)
rslt = session.execute(pStatement, [resultpath, workflowid])