JSONDecodeError:期望值:第1行第1列(char 0),带有pydruid

时间:2018-02-23 22:19:58

标签: python-3.x druid

我们在德鲁伊数据库中有数据,我们需要使用python读取它以进行进一步的分析处理。我正在尝试使用pydruid包阅读德鲁伊数据库。我使用的是python 3.5。但是,当我运行execute语句时,我收到错误:

以下是我正在运行的代码:

*from pydruid.db import connect
conn = connect(host='XXXXXXX', port=8082, path='/druid/v2', scheme='http')
curs = conn.cursor()
curs.execute("""SELECT * FROM wikipedia LIMIT 10""")*

我得到错误:

JSONDecodeError Traceback (most recent call last)
in ()
----> 1 curs.execute("""SELECT * FROM wikipedia LIMIT 10""")
/apps/cmor/anaconda3/lib/python3.5/site-packages/pydruid-0.3.1-py3.5.egg/pydruid/db/api.py in g(self, *args, **kwargs)
39 raise exceptions.Error(
40 '{klass} already closed'.format(klass=self.class.name))
---> 41 return f(self, *args, **kwargs)
42 return g
43
/apps/cmor/anaconda3/lib/python3.5/site-packages/pydruid-0.3.1-py3.5.egg/pydruid/db/api.py in execute(self, operation, parameters)
187 # let's consume it and insert it back.
188 results = self._stream_query(query)
--> 189 first_row = next(results)
190 self._results = itertools.chain([first_row], results)
191
/apps/cmor/anaconda3/lib/python3.5/site-packages/pydruid-0.3.1-py3.5.egg/pydruid/db/api.py in _stream_query(self, query)
267 # raise any error messages
268 if r.status_code != 200:
--> 269 payload = r.json()
270 msg = (
271 '{error} ({errorClass}): {errorMessage}'.format(**payload)
/apps/cmor/anaconda3/lib/python3.5/site-packages/requests/models.py in json(self, **kwargs)
892 # used.
893 pass
--> 894 return complexjson.loads(self.text, **kwargs)
895
896 @property
/apps/cmor/anaconda3/lib/python3.5/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
317 parse_int is None and parse_float is None and
318 parse_constant is None and object_pairs_hook is None and not kw):
--> 319 return _default_decoder.decode(s)
320 if cls is None:
321 cls = JSONDecoder
/apps/cmor/anaconda3/lib/python3.5/json/decoder.py in decode(self, s, _w)
337
338 """
--> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()
341 if end != len(s):
/apps/cmor/anaconda3/lib/python3.5/json/decoder.py in raw_decode(self, s, idx)
355 obj, end = self.scan_once(s, idx)
356 except StopIteration as err:
--> 357 raise JSONDecodeError("Expecting value", s, err.value) from None
358 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)*

1 个答案:

答案 0 :(得分:0)

如PyDruid documentation

中所述
  

pydruid应该与Python 2.x一起运行,并且已知与Python 2.7.5一起运行。