2

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
4

1 回答 1

7

通过 SQL 检查“OUser”类是否存在,执行以下命令:

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

通过 Java API:

OClass cls = db.getMetadata().getSchema().getClass("OUser");
于 2015-02-04T23:04:50.207 回答