连接配置
UltipaConfig 配置项:
配置项 | 类型 | 说明 |
---|---|---|
hosts | []string | Ultipa 数据库集群地址列表 |
timeout | int | 超时时间(秒) |
consistency | bool | 是否使用读一致性(默认为True) |
username | str | 用户名 |
password | str | 密码 |
maxRecvSize | int | 接收数据的最大字节数 |
defaultGraph | str | 默认图集名称 |
heartBeat | int | 所有实例的心跳时间(秒),0 则为关闭心跳时间 |
responseWithRequestInfo | bool | 是否返回请求时相关信息 |
uqlLoggerConfig | LoggerConfig | 日志配置相关 |
debug | bool | 是否使用 debug 模式 |
说明:如果Debug为True,但是用户没有设置uqlLoggerConfig,那么SDK将会初始化一个uqlLoggerConfig 用于输出Debug 信息不会写文件。
LoggerConfig 配置项:
配置项 | 类型 | 说明 |
---|---|---|
name | str | logger 的名称 |
fileName | str | 日志文件的名称 |
isWriteToFile | bool | 是否将日志写进文件 |
isStream | bool | 是否将日志输出到屏幕 |
level | logging | 日志的等级,默认为 INFO |
示例:
from ultipa import Connection
from ultipa import UltipaConfig
from ultipa.types.types import LoggerConfig
defaultConfig = UltipaConfig()
defaultConfig.hosts = ["host:port"]
defaultConfig.username = "root"
defaultConfig.password = "root"
conn = Connection.GetConnection(defaultConfig=defaultConfig)
请求配置
RequestConfig 配置项:
配置项 | 类型 | 说明 |
---|---|---|
graphName | str | 当前请求使用的图集名 |
timeout | int | 当前请求的超时间(秒) |
host | str | 向指定的主机发送请求 |
useMaster | bool | 是否使用 leader 来保证读一致性 |
retry | Retry | 请求失败重试配置 |
stream | bool | 是否流式返回 |
threadNum | int | 指定线程数 |
示例:
from ultipa import Connection
from ultipa import UltipaConfig,RequestConfig
defaultConfig = UltipaConfig()
defaultConfig.hosts = ["host:port"]
defaultConfig.username = "root"
defaultConfig.password = "root"
conn = Connection.GetConnection(defaultConfig=defaultConfig)
ret = conn.uql("find().nodes() as nodes return nodes{*} limit 10",RequestConfig())