如何使用python在orientdb查询的where子句中使用变量

时间:2016-09-14 09:52:10

标签: python orientdb

import pyorient

# create connection 
client = pyorient.OrientDB("localhost", 2424) 

# open databse 
client.db_open( "testDB", "admin", "admin" ) 
requiredObj = client.command(" select out().question as qlist,out().seq as qseq,out().pattern as pattern,out().errormsg as errormsg from chat where app_cat='%s' and module='%s' and type='%s' and prob_cat='%s' ",(appCategory,module,type,problemCategory))

for data in requiredObj :
    print data

以上一个不起作用请建议替代方式

1 个答案:

答案 0 :(得分:1)

您可以使用此命令

requiredObj = client.command("select from chat where name='%s'" % "chat 1");

requiredObj = client.command("select from chat where name='%s' and room='%s'" % ("chat 1","1"));

希望有所帮助