Check class creation in OrientDB

ぃ、小莉子 提交于 2019-12-11 04:05:01

问题


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

回答1:


Via SQL to check the existence of "OUser" class execute this:

SELECT FROM ( SELECT expand( classes ) FROM metadata:schema ) WHERE name = 'OUser'

Via Java API:

OClass cls = db.getMetadata().getSchema().getClass("OUser");


来源:https://stackoverflow.com/questions/28288268/check-class-creation-in-orientdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!