Connection Configuration
The Configuration for connection and request to ultipa graph:
Key | Type | Description |
---|---|---|
hosts | List[str] | Ultipa Graph hosts list |
defaultGraph | str | defaul graphset name |
timeoutWithSeconds | int | the timeout seconds for any request |
responseWithRequestInfo | bool | if return request info |
consistency | bool | if use Consistency Read (true by default) |
uqlLoggerConfig | LoggerConfig | logger configuration |
heartBeat | int | the seconds of heartbeat to all instances, 0 means turn off heartbeat |
maxRecvSize | int | max byte when receive data |
Debug | bool | if open debug mode |
When setting
Debug
as True without setting uqlLoggerConfig, the SDK will initialize a uqlLoggerConfig for debugging and not write to file.
LoggerConfig:
Key | Type | Description |
---|---|---|
name | str | name of logger |
fileName | str | name of log file |
isWriteToFile | bool | if write log as file |
isStream | bool | if output log to console |
level | logging | level of log, by default is INFO |
RequestConfig:
Key | Type | Description |
---|---|---|
graphSetName | str | name of graphset used by current request |
timeoutWithSeconds | int | the timeout seconds for any request |
retry | Retry | retry config when request failed |
stream | bool | if return in stream |
useHost | str | send request to a designated host |
useMaster | bool | if send request to the leader |
Create Connection
from ultipa import Connection
from ultipa import UltipaConfig
from ultipa.types.types import LoggerConfig
defaultConfig = UltipaConfig()
conn = Connection.GetConnection(hosts=["host:port"],username="root",
password="root",defaultConfig=defaultConfig)
Execute UQL
from ultipa import Connection
from ultipa import UltipaConfig,RequestConfig
defaultConfig = UltipaConfig()
conn = Connection.GetConnection(
hosts=["host:port"],
username="root", password="root",defaultConfig=defaultConfig)
ret = conn.uql("find().nodes() as nodes return nodes{*} limit 10",RequestConfig())