Orientdb-python-interface
提供:Dev Guides
OrientDB-Pythonインターフェース
Python用のOrientDBドライバーは、バイナリプロトコルを使用します。 PyOrientは、OrientDBをPythonに接続するのに役立つgitハブプロジェクト名です。 OrientDBバージョン1.7以降で動作します。
次のコマンドは、PyOrientをインストールするために使用されます。
pip install pyorient
*demo.py* という名前のスクリプトファイルを使用して、次のタスクを実行できます-
- クライアントインスタンスを作成すると、接続が作成されます。
- DB_Demo という名前のDBを作成します。
- DB_Demoという名前のDBを開きます。
- クラス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')")
次のコマンドを使用して上記のスクリプトを実行します。
$ python demo.py