PyOrient Client
The base module in PyOrient provides a Python wrapper for the OrientDB Binary Protocol. Using this wrapper, you can initialize a client instance within your application, then operate on the OrientDB Server through this instance.
In order to use the PyOrient Client, you need to import the base module into your application.
import pyorient
Initializing the Client
In order to use the PyOrient Client, you need to initialize a client instance in your application. By convention, this instance is called client
, but you can use any object name you prefer.
To use the client, first initialize a the client object, then connect to the OrientDB Server:
client = pyorient.OrientDB("localhost", 2424)
session_id = client.connect("admin", "admin_passwd")
Here, you initialize the client
object to connect to OrientDB through the localhost interface on port 2424. Then, you establish a connection with the Server, using the username admin
and the password admin_passwd
.
Server Shutdown
From within your application, you can shut down the OrientDB Server. The user that initiates the shutdown must have shutdown permissions in the orientdb-server-config.xml
configuration file, (for instance, the root
user on the OrientDB Server).
client.shutdown('root', 'root_passwd')
Working with the Client
Within your application, once you have initialized the PyOrient Client this object provides you with an interface in working databases on the OrientDB Server.
command()
This method issues SQL commands.batch()
This method issues batch commands.data_cluster_add()
This method creates new clusters on the database.data_cluster_count()
This method counts the numbers of records in an array of clusters.data_cluster_data_range()
This method retrieves all records in the given cluster.data_cluster_drop()
This method removes a cluster from the database.db_count_records()
This method counts the number of records on a database.db_create()
This method creates databases.db_drop()
This method removes databases.db_exists()
This method determines if a database exists.db_list()
This method lists databases on the server.db_open()
This method opens a database on the server.db_reload()
This method reloads the database on the client.db_size()
This method returns the size of the database.get_session_token()
` This method returns the client session token.query()
This method issues synchronous queries to the database.query_async()
This method issues asynchronous queries to the database.record_create()
This method creates records on the database.record_delete()
This method removes records from the database.record_load()
This method retrieves records from the database.record_update()
This method updates records on the database.set_session_token()
This method enables and loads a token for the client session.tx_commit()
THis method initializes a control object for transactions.