Ham*_*FzM 2 python orientdb python-2.7 pyorient
我正在尝试使用pyorient
驱动程序创建类,但有时如果类存在,我有类存在消息.有没有办法检查OrientDB python驱动程序中是否存在类?以下是我创建类的示例代码的一部分......
@classmethod
def create(cls):
cls._cluster_id = OrientEngine.client.command("CREATE CLASS %s EXTENDS V" % cls.__name__)
return cls._cluster_id
Run Code Online (Sandbox Code Playgroud)
通过SQL检查"OUser"类的存在执行:
SELECT FROM ( SELECT expand( classes ) FROM metadata:schema ) WHERE name = 'OUser'
Run Code Online (Sandbox Code Playgroud)
通过Java API:
OClass cls = db.getMetadata().getSchema().getClass("OUser");
Run Code Online (Sandbox Code Playgroud)