2016-09-14 47 views
-2

代碼orientdb查詢的WHERE子句中的變量如何使用其中使用python

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 

上面的一個工作不請提出替代方式

+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")); 

希望它有幫助