DefaultConfig
Properties |
Type |
Description |
timeoutWithSeconds |
int |
Timeout threshold, 3600s be default |
graphSetName |
str |
The name of graphset, 'default' if not configured |
responseWithRequestInfo |
bool |
To return with the requested information; False by default |
readModeNonConsistency |
bool |
Inconsistency when read mode; False by default |
uqlLoggerConfig |
LoggerConfig |
logger configuration, and the manual instantiation is required; None by default |
LoggerConfig
Properties |
Type |
Description |
name |
str |
The logger name |
fileName |
str |
The logger file name |
isWriteToFile |
bool |
To write log as file |
isStream |
bool |
To return log to console |
level |
logging |
The log level, INFO by default |
UltipaResponse
Properties |
Type |
Description |
status |
Status |
The status of UQL task |
data |
List[DataItem] |
the result of UQL |
total_time |
int |
The total time cost |
engine_time |
Int |
The engine time cost |
req |
ReturnReq |
The request |
statistics |
UltipaStatistics |
The statistics of the UQL execution such as time cost and affected number of nodes/edges |
User Authentication
- Authentication requires users to provide username and password when establishing connection with Server:
from ultipa import Connection, DefaultConfig, ULTIPA_REQUEST, ULTIPA
defaultConfigExample = DefaultConfig()
hostList = ['host:port','host1:port1','host2:port2']
conn = Connection.GetConnection(hosts=hostList, username="root", password="root",
defaultConfig=defaultConfigExample)
Use cases
- For non-cluster deployment, obtain the connection object (that provides all the Ultipa operations) through
Connection
after the authentication is passed:
from ultipa import Connection
conn = Connection(host='host:port', username="root", password="root")
ret = conn.test()
print(ret)
# A true 'ret' indicates a successful connection to Ultipa Server
# The graphset 'default' is used by default
- For cluster deployment, the connection object is obtained through
Connection.GetConnection
, all instances of the cluster are passed in through parameter hosts
:
from ultipa import Connection, DefaultConfig, ULTIPA_REQUEST, ULTIPA
defaultConfigExample = DefaultConfig()
hostList = ['host:port','host1:port1','host2:port2']
conn = Connection.GetConnection(hosts=hostList, username="root", password="root",
defaultConfig=defaultConfigExample)
ret = conn.test()
print(ret)
# Configurations of the connection object is done through 'defaultConfig'
from ultipa import Connection,DefaultConfig, ULTIPA_REQUEST, ULTIPA
# 1.
defaultConfigExample = DefaultConfig(graph="testGraph")
conn = Connection(host='host:port', username="root", password="root",
defaultConfig=defaultConfigExample)
# 2. Specify the desired graphset in the object 'Common' when calling a method
conn.searchNode(ULTIPA_REQUEST.SearchNode(limit=10), ULTIPA_REQUEST.Common(graph="testGraph"))
ret = conn.test()
print(ret)