首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pyorient批处理解析问题

Pyorient批处理解析问题
EN

Stack Overflow用户
提问于 2016-01-08 18:41:38
回答 1查看 456关注 0票数 2

我目前正在尝试使用pyorient填充orientdb图形数据库。总的来说,一切都运行得很好。但是,我的一个命令遇到了一个解析问题。在Python中,如果我运行以下代码:

代码语言:javascript
复制
>>> ab = 'UPDATE Patent SET  primary_id = 676, original_abstract = set(original_abstract, "<p num=\\"0000\\">The present invention relates to compounds of the general formula (I) wherein\\n\\nR<sup>1</sup> is the group (A) or (B) or (C) or (D); R<sup>2</sup> is a non aromatic\\n\\nheterocycle, or is OR\' or N(R\\")<sub>2</sub>; R\' is lower alkyl,\\n\\nlower alkyl substituted by halogen or -(CH<sub>2</sub>)<sub>n</sub>-cycloalkyl;\\n\\nR\\" is lower alkyl; R<sup>3</sup> is NO<sub>2</sub>, CN or SO<sub>2</sub>R\';\\n\\nR<sup>4 </sup>is hydrogen, hydroxy, halogen, NO<sub>2</sub>, lower alkyl, lower\\n\\nalkyl, substituted by halogen, lower alkoxy, SO<sub>2</sub>R\' or C(O)OR\\";\\n\\nR<sup>5</sup>/R<sup>6</sup>/R<sup>7</sup> are hydrogen, halogen, lower alkyl\\n\\nor lower alkyl, substituted by halogen; X<sup>1</sup>/X<sup>1\\u00bf</sup>\\n\\nare CH or N, with the proviso that X<sup>1</sup>/X<sup>1\\u00bf</sup> are not simultaneously\\n\\nCH; X<sup>2</sup> is O, S, NH or N(lower alkyl); n is 0, l or 2; and to pharmaceutically\\n\\nactive acid addition salts and to their use in the treatment of neurological and\\n\\nneuropsychiatric disorders.</p>")  UPSERT WHERE primary_id = 676'
>>> client.batch(ab)

我得到以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/orient.py", line 402, in batch
.prepare(( QUERY_SCRIPT, ) + args).send().fetch_response()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/commands.py", line 145, in fetch_response
    super( CommandMessage, self ).fetch_response()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 256, in fetch_response
self._decode_all()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 240, in _decode_all


 self._decode_header()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 192, in _decode_header
    [ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientCommandException: com.orientechnologies.orient.core.sql.parser.TokenMgrError - Lexical error at line 1, column 311.  Encountered: <EOF> after : "\"<p num=\\\"0000\\\">The present invention relates to compounds of the general formula (I) wherein\\n\\nR<sup>1</sup> is the group (A) or (B) or (C) or (D); R<sup>2</sup> is a non aromatic\\n\\nheterocycle, or is OR\' or N(R\\\")<sub>2</sub>"

如果我使用命令运行这个命令,我也会得到错误:

代码语言:javascript
复制
>>> client.command(ab)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/orient.py", line 398, in command
    .prepare(( QUERY_CMD, ) + args).send().fetch_response()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/commands.py", line 145, in fetch_response
    super( CommandMessage, self ).fetch_response()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 256, in fetch_response
    self._decode_all()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 240, in _decode_all
    self._decode_header()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 192, in _decode_header
    [ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientCommandException: com.orientechnologies.orient.core.sql.OCommandSQLParsingExceptioncom.orientechnologies.orient.core.exception.OSerializationException - Error on parsing command at position #0: Error on reading parameters in: set(original_abstract, "<p num="0000">The present invention relates to compounds of the general formula (I) wherein

R<sup>1</sup> is the group (A) or (B) or (C) or (D); R<sup>2</sup> is a non aromatic

heterocycle, or is OR' or N(R")<sub>2</sub>; R' is lower alkyl,

lower alkyl substituted by halogen or -(CH<sub>2</sub>)<sub>n</sub>-cycloalkyl;

R" is lower alkyl; R<sup>3</sup> is NO<sub>2</sub>, CN or SO<sub>2</sub>R';

R<sup>4 </sup>is hydrogen, hydroxy, halogen, NO<sub>2</sub>, lower alkyl, lower

alkyl, substituted by halogen, lower alkoxy, SO<sub>2</sub>R' or C(O)OR";

R<sup>5</sup>/R<sup>6</sup>/R<sup>7</sup> are hydrogen, halogen, lower alkyl

or lower alkyl, substituted by halogen; X<sup>1</sup>/X<sup>1¿</sup>

are CH or N, with the proviso that X<sup>1</sup>/X<sup>1¿</sup> are not simultaneously

CH; X<sup>2</sup> is O, S, NH or N(lower alkyl); n is 0, l or 2; and to pharmaceutically

active acid addition salts and to their use in the treatment of neurological and

neuropsychiatric disordersFound invalid ) character at position 229 of text original_abstract, "<p num="0000">The present invention relates to compounds of the general formula (I) wherein

R<sup>1</sup> is the group (A) or (B) or (C) or (D); R<sup>2</sup> is a non aromatic

heterocycle, or is OR' or N(R")<sub>2</sub>. Ensure it is opened and closed correctly.

但是,我发现如果不将original_abstract下的信息作为集合添加,则使用命令时会起作用:

代码语言:javascript
复制
>>> aba = 'UPDATE Patent SET  primary_id = 676, original_abstract = "<p num=\\"0000\\">The present invention relates to compounds of the general formula (I) wherein\\n\\nR<sup>1</sup> is the group (A) or (B) or (C) or (D); R<sup>2</sup> is a non aromatic\\n\\nheterocycle, or is OR\' or N(R\\")<sub>2</sub>; R\' is lower alkyl,\\n\\nlower alkyl substituted by halogen or -(CH<sub>2</sub>)<sub>n</sub>-cycloalkyl;\\n\\nR\\" is lower alkyl; R<sup>3</sup> is NO<sub>2</sub>, CN or SO<sub>2</sub>R\';\\n\\nR<sup>4 </sup>is hydrogen, hydroxy, halogen, NO<sub>2</sub>, lower alkyl, lower\\n\\nalkyl, substituted by halogen, lower alkoxy, SO<sub>2</sub>R\' or C(O)OR\\";\\n\\nR<sup>5</sup>/R<sup>6</sup>/R<sup>7</sup> are hydrogen, halogen, lower alkyl\\n\\nor lower alkyl, substituted by halogen; X<sup>1</sup>/X<sup>1\\u00bf</sup>\\n\\nare CH or N, with the proviso that X<sup>1</sup>/X<sup>1\\u00bf</sup> are not simultaneously\\n\\nCH; X<sup>2</sup> is O, S, NH or N(lower alkyl); n is 0, l or 2; and to pharmaceutically\\n\\nactive acid addition salts and to their use in the treatment of neurological and\\n\\nneuropsychiatric disorders.</p>"  UPSERT WHERE primary_id = 676'
>>> client.command(aba)
['1']

然而,client.batch仍然不能正确处理这一点:

代码语言:javascript
复制
>>> client.batch(aba)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/orient.py", line 402, in batch
    .prepare(( QUERY_SCRIPT, ) + args).send().fetch_response()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/commands.py", line 145, in fetch_response
    super( CommandMessage, self ).fetch_response()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 256, in fetch_response
    self._decode_all()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 240, in _decode_all
    self._decode_header()
  File "/Users/shaungupta/anaconda/lib/python2.7/site-packages/pyorient/messages/base.py", line 192, in _decode_header
    [ exception_message.decode( 'utf8' ) ]
pyorient.exceptions.PyOrientCommandException: com.orientechnologies.orient.core.exception.OSerializationException - Found invalid ) character at position 274 of text UPDATE Patent SET  primary_id = 676, original_abstract = "<p num=\"0000\">The present invention relates to compounds of the general formula (I) wherein\n\nR<sup>1</sup> is the group (A) or (B) or (C) or (D); R<sup>2</sup> is a non aromatic\n\nheterocycle, or is OR' or N(R\")<sub>2</sub>; R' is lower alkyl,\n\nlower alkyl substituted by halogen or -(CH<sub>2</sub>)<sub>n</sub>-cycloalkyl;\n\nR\" is lower alkyl; R<sup>3</sup> is NO<sub>2</sub>, CN or SO<sub>2</sub>R';\n\nR<sup>4 </sup>is hydrogen, hydroxy, halogen, NO<sub>2</sub>, lower alkyl, lower\n\nalkyl, substituted by halogen, lower alkoxy, SO<sub>2</sub>R' or C(O)OR\";\n\nR<sup>5</sup>/R<sup>6</sup>/R<sup>7</sup> are hydrogen, halogen, lower alkyl\n\nor lower alkyl, substituted by halogen; X<sup>1</sup>/X<sup>1\u00bf</sup>\n\nare CH or N, with the proviso that X<sup>1</sup>/X<sup>1\u00bf</sup> are not simultaneously\n\nCH; X<sup>2</sup> is O, S, NH or N(lower alkyl); n is 0, l or 2; and to pharmaceutically\n\nactive acid addition salts and to their use in the treatment of neurological and\n\nneuropsychiatric disorders.</p>"  UPSERT WHERE primary_id = 676. Ensure it is opened and closed correctly.

在orientdb控制台中直接运行string ab也会给出相同的错误,但是在orientdb控制台中运行string aba可以很好地工作,所以我不能理解为什么aba不能使用pyorient批处理命令(我还成功地在orientdb控制台中作为begin/commit事务的一部分运行了aba )。

有人知道为什么这个命令通过client.command而不是client.batch工作吗?我需要将此命令作为一批命令的一部分运行,因此需要找到修复程序.....理想情况下,我希望在string ab中使用命令,因为我需要跟踪匹配节点的任何新信息,因此我需要将原始摘要添加为一个集合来工作。

根据我所看到的,这是命令执行程序的解析限制,但如果我在这里做错了什么,请告诉我……

谢谢!!

EN

回答 1

Stack Overflow用户

发布于 2016-07-22 08:11:44

第一个错误显示您的命令中有文件结束(EOF)字符,该字符可能看不见,如果它是从其他地方复制的,这是很常见的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34675020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档