检查 OrientDB 中的类创建 [英] Check class creation in OrientDB
本文介绍了检查 OrientDB 中的类创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 pyorient
驱动程序创建类,但有时如果类存在,我会收到类存在消息.有没有办法检查OrientDB python驱动程序中是否存在类?这是我创建类的示例代码的一部分...
I'm trying to create classes with pyorient
driver but sometime if class exists I got class exists message. Is there a way to check whether class is exists or not in OrientDB python driver? Here is part of my sample code for class creation...
@classmethod
def create(cls):
cls._cluster_id = OrientEngine.client.command("CREATE CLASS %s EXTENDS V" % cls.__name__)
return cls._cluster_id
推荐答案
通过SQL检查OUser"类是否存在执行:
Via SQL to check the existence of "OUser" class execute this:
SELECT FROM ( SELECT expand( classes ) FROM metadata:schema ) WHERE name = 'OUser'
通过 Java API:
Via Java API:
OClass cls = db.getMetadata().getSchema().getClass("OUser");
这篇关于检查 OrientDB 中的类创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文