python - Cassandra: 'unicode' does not have the buffer interface -
i try use these both prepared statements in django app:
readings = "select * readings" readings_by_user_id = "select * readings user_id=?" i query against db with:
def get_all(self): query = self.session.prepare(ps.all_readings) all_readings = self.session.execute(query) return all_readings def get_all_by_user_id(self, user_id): query = self.session.prepare(ps.readings_by_user_id) readings = self.session.execute(query, [user_id]) return readings the first of both works pretty well. second gives me:
error 2015-07-08 09:42:56,634 | views::exception_handler 47 | ('unable complete operation against hosts', {<host: localhost data1>: typeerror("'unicode' not have buffer interface",)}) can tell me happened here? understand, there must unicode string somewhere not have buffer interface. string meant? prepared statement?
here stacktrace in addition:
traceback (most recent call last): file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/rest_framework/views.py", line 448, in dispatch response = handler(request, *args, **kwargs) file "/users/me/workspace/project/readings/views.py", line 36, in get_by_user_id readings = self.tr_dao.get_all_by_user_id(user_id) file "/users/me/workspace/project/readings/dao.py", line 22, in get_all_by_user_id readings = self.session.execute(query, [user_id], timeout=60) file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/cassandra/cluster.py", line 1405, in execute result = future.result(timeout) file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/cassandra/cluster.py", line 2967, in result raise self._final_exception
if on python 2 fix it
def get_all_by_user_id(self, user_id): query = self.session.prepare(ps.readings_by_user_id) readings = self.session.execute(query, [str(user_id)]) return readings
Comments
Post a Comment