这是 pyorient github 中已关闭问题#211 的摘录。虽然可能已经有了一些答案,但我在这里发布了这个错误,因为错误并不明显,并提供了一个使用 pyorient 和测试类是否存在的示例。所以这里是摘录:
我正在测试如何查询一个类的存在,所以我在这里玩了用作GRAPH 示例的 Animals db
### Create the Vertex Animal
cluster_id = client.command("create class Animal extends V")
print(cluster_id)
### Insert a new value
client.command("insert into Animal set name = 'rat', specie = 'rodent'")
然后,当使用 db_name 'Animals' 查询数据库时,我收到以下异常响应(它也发生在此处未描述的其他情况下):
PyOrientCommandException: -
我的查询以测试该类的存在:
sql_query = "SELECT FROM ( SELECT expand( classes ) FROM metadata:schema ) WHERE name = '{}')".format('Animal')
client.query(sql_query)
完整的输出错误:
---------------------------------------------------------------------------
PyOrientCommandException Traceback (most recent call last)
<ipython-input-21-a6b7ac6435cb> in <module>()
----> 1 client.query(sql_query)
/home/jo/anaconda3/envs/aenv/lib/python3.5/site-packages/pyorient/orient.py in query(self, *args)
417 def query(self, *args):
418 return self.get_message("CommandMessage") \
--> 419 .prepare(( QUERY_SYNC, ) + args).send().fetch_response()
420
421 def query_async(self, *args):
/home/jo/anaconda3/envs/aenv/lib/python3.5/site-packages/pyorient/messages/commands.py in fetch_response(self)
142
143 # decode header only
--> 144 super( CommandMessage, self ).fetch_response()
145
146 if self._command_type == QUERY_ASYNC:
/home/jo/anaconda3/envs/aenv/lib/python3.5/site-packages/pyorient/messages/base.py in fetch_response(self, *_continue)
259 # already fetched, get last results as cache info
260 elif len(self._body) is 0:
--> 261 self._decode_all()
262 self.dump_streams()
263 return self._body
/home/jo/anaconda3/envs/aenv/lib/python3.5/site-packages/pyorient/messages/base.py in _decode_all(self)
243
244 def _decode_all(self):
--> 245 self._decode_header()
246 self._decode_body()
247
/home/jo/anaconda3/envs/aenv/lib/python3.5/site-packages/pyorient/messages/base.py in _decode_header(self)
176 raise PyOrientCommandException(
177 exception_class.decode( 'utf8' ),
--> 178 [ exception_message.decode( 'utf8' ) ]
179 )
180
PyOrientCommandException: -
会不会像得到一个utf8
解码无法识别的“影子”字符?我正在使用 Jupyter 笔记本上的代码运行 Ubuntu 16.04,ANACONDA python 发行版 3.5,pyorient v.1.4.9
有什么帮助吗?