简体   繁体   English

为OrientDB编码(无法发送文字字符串)

[英]Encoding for OrientDB (can't send a literal string)

I have the next problem. 我有下一个问题。 I need to create a vertex with a propertyA with a value 'المساء'. 我需要创建一个带有属性A的顶点,其值为'المساء'。 The problem is from python, python CAN'T send the string 'المساء' so... 问题出在python,python无法发送字符串'المساء',所以...

I know I need to do a encode, like the next: 我知道我需要像下面这样编码:

>>>a = 'المساء'
>>>b = a.encode('cp270')
>>>print b
>>>'\x9f\xe9\xea\xab\x9f\x98'

But with this encode OrientDB won't work. 但是使用这种编码,OrientDB将无法正常工作。 I think that I need an ascii encode. 我认为我需要一个ascii编码。

There is the problem (without response): https://github.com/orientechnologies/orientdb/issues/5860 存在问题(无响应): https : //github.com/orientechnologies/orientdb/issues/5860

Anyone that know about OrientDB can help me? 任何了解OrientDB的人都可以帮助我吗? Thank in advance! 预先感谢!

I have tried with this code with orientDb version 2.2.7 我已经尝试使用OrientDb 2.2.7版的此代码

import pyorient 

db_name='MyDb'

print("connection to the server...")
client=pyorient.OrientDB("localhost",2424)
client.set_session_token(True)
session_id=client.connect("root","root")

client.db_open( db_name, "admin", "admin" )

myFunction = 'insert into v(name) values("المساء")'
client.command(myFunction);

client.db_close() 

and it worked for me 对我有用

在此处输入图片说明

Hope it helps. 希望能帮助到你。

Using python I can do this: 使用python我可以做到这一点:

>>> a = 'غريبديالى#مخيسةالعز'
>>> type(a)
<type 'str'>
>>> b = a.decode('utf8')
>>> b
u'\u063a\u0631\u064a\u0628\u062f\u064a\u0627\u0644\u0649#\u0645\u062e\u064a\u0633\u0629\u0627\u0644\u0639\u0632'
>>> print b
غريبديالى#مخيسةالعز

So, if I put a query like the next will create a vertex with the next result: 因此,如果我输入类似next的查询,则会创建具有下一个结果的顶点:

query = 'create vertex v content {"property":"%s"}' %b

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM