OrientDB Python 接口
用于 Python 的 OrientDB 驱动程序使用二进制协议。 PyOrient 是 git hub 项目名称,它有助于将 OrientDB 与 Python 连接起来。它适用于 OrientDB 1.7 及更高版本。
以下命令用于安装PyOrient。
您可以使用名为
demo.py 的脚本文件来执行以下任务-
创建客户端实例意味着创建连接。
创建名为 DB_Demo 的数据库。
打开名为 DB_Demo 的数据库。
创建类 my_class。
创建属性 ID 和名称。
将记录插入我的班级。
//create connection
client = pyorient.OrientDB("localhost", 2424)
session_id = client.connect( "admin", "admin")
//create a databse
client.db_create( db_name, pyorient.DB_TYPE_GRAPH, pyorient.STORAGE_TYPE_MEMORY )
//open databse
client.db_open( DB_Demo, "admin", "admin")
//create class
cluster_id = client.command( "create class my_class extends V" )
//create property
cluster_id = client.command( "create property my_class.id Integer" )
cluster_id = client.command( "create property my_class.name String" )
//insert record
client.command("insert into my_class ( 'id','’name' ) values( 1201, 'satish')")
使用以下命令执行上述脚本。