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