无法从 python 客户端插入到 cratedb



使用python客户端。

我得到了一个连接,然后提交了一个带有参数arg数据硬编码的insert语句。但是,出现错误。

from crate import client
con = client.connect("http://webservicesbigmac.richmond.edu:4200")
cursor = con.cursor()
print cursor
cursor.execute("INSERT INTO logs (client_ip) VALUES (?)", ("66.249.67.49"))

我可以在崩溃客户端中运行这个查询,它可以在中运行

cr>插入日志(client_ip)值('66.249.67.49');

INSERT OK,1行受影响(0.001秒)

我确信我做错了什么,只是不确定是什么。

这个堆栈跟踪

<crate.client.cursor.Cursor object at 0x10e40bcd0>
Traceback (most recent call last):
  File "/Users/epalmer/projects/cratedbload/sqlload2.py", line 11, in <module>
    cursor.execute("INSERT INTO logs (client_ip) VALUES (?)", ("66.249.67.49"))
  File "/Library/Python/2.7/site-packages/crate/client/cursor.py", line 51, in execute
    self._result = self.connection.client.sql(sql, parameters, bulk_parameters)
  File "/Library/Python/2.7/site-packages/crate/client/http.py", line 202, in sql
    content = self._json_request('POST', self.path, data=data)
  File "/Library/Python/2.7/site-packages/crate/client/http.py", line 362, in _json_request
    self._raise_for_status(response)
  File "/Library/Python/2.7/site-packages/crate/client/http.py", line 348, in _raise_for_status
    raise ProgrammingError(error.get('message', ''), error_trace=error_trace)
crate.client.exceptions.ProgrammingError: SQLActionException[Failed to parse source [{"args":     "66.249.67.49", "stmt": "INSERT INTO logs (client_ip) VALUES (?)"}]]

我猜(从未使用过cratedata),但从其中一个选择的示例来看,绑定变量列表似乎需要是一个元组。您只传入一个值-try:("66.249.67.49", )注意逗号

相关内容

  • 没有找到相关文章

最新更新