Reputation: 79
Using the python client.
I'm getting a connection back and then submitting a insert statement with parameter arg data hard coded. Getting an error however.
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"))
I can run this query in the crash client and it works
cr> INSERT INTO logs (client_ip) VALUES ('66.249.67.49');
INSERT OK, 1 row affected (0.001 sec)
I'm sure I'm doing something wrong, just not certain what it is.
this stack trace
<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 (?)"}]]
Upvotes: 2
Views: 603
Reputation: 29740
I'm guessing (never used cratedata), but from one of the select examples, it appears that the bind variable list needs to be a tuple. You're only passing in a single value - try: ("66.249.67.49", )
Note the comma
Upvotes: 3