Data Type
Ultipa property types and Python data types are correlated as following pairs:
Ultipa | Python |
---|---|
string | string |
text | string |
float | float |
double | float |
int32 | int |
uint32 | int |
int64 | int |
uint64 | int |
datetime | string |
timestamp | string, int |
insertNodesBatchBySchema()
insertNodesBatchBySchema()
will insert multiple nodes of a particular node schema. The properties carried in the values
of nodes should be consistent with those declared in the schema structure.
Method and class:
def insertNodesBatchBySchema(self,
schema: ULTIPA_REQUEST.Schema,
rows: List[ULTIPA.Node],
config: ULTIPA_REQUEST.InsertConfig
) -> ULTIPA_RESPONSE.InsertResponse
class Schema:
def __init__(self,
name: str,
properties: List[Property],
desc: str = None,
type: str = None,
DBType: ULTIPA.DBType = None,
total: int = None
)
class Property:
def __init__(self, name: str, type: ULTIPA.PropertyType = None, desc: str = None)
Example: Insert multiple nodes into schema 'customer' of graphset 'test', use insert mode
from ultipa import Connection, UltipaConfig, InsertConfig
from ultipa import ULTIPA_REQUEST, ULTIPA
# omit code of establishing server connection 'conn' using graphset 'default'
schema = ULTIPA_REQUEST.Schema(
"customer",
[
ULTIPA_REQUEST.Property("name", ULTIPA.PropertyType.PROPERTY_STRING),
ULTIPA_REQUEST.Property("level", ULTIPA.PropertyType.PROPERTY_INT32)
]
)
rows = [
ULTIPA.EntityRow(values = {"name": "Paal", "level": 2}),
ULTIPA.EntityRow(values = {"name": "Alice", "level": 1})
]
req = conn.insertNodesBatchBySchema(
schema,
rows,
InsertConfig(ULTIPA.InsertType.NORMAL, "test")
)
req.Print()
insertNodesBatchAuto()
insertNodesBatchAuto()
will insert multiple nodes of multiple node schemas. The nodes should carry schema
, and the properties carried in the values
of nodes should be consistent with those defined in the graphset.
Method and class:
def insertNodesBatchAuto(self,
nodes: List[ULTIPA.Node],
config: ULTIPA_REQUEST.InsertConfig
) -> ULTIPA_RESPONSE.ResponseBatchAutoInsert
Example: Insert multiple nodes into multiple schemas of graphset 'test', use upsert mode
from ultipa import Connection, UltipaConfig, InsertConfig
from ultipa import ULTIPA_REQUEST, ULTIPA
# omit code of establishing server connection 'conn' using graphset 'default'
rows = [
ULTIPA.EntityRow(values = {"name": "Paal", "level": 3}, schema = "customer", id = "CUST000A2D"),
ULTIPA.EntityRow(values = {"balance": 4000.0, "level": 1}, schema = "card", id = "CARD000901")
]
req = conn.insertNodesBatchAuto(
rows,
InsertConfig(ULTIPA.InsertType.UPSERT,"test")
)
req.Print()
insertEdgesBatchBySchema()
insertEdgesBatchBySchema()
will insert multiple edges of a particular edge schema. The properties carried in the values
of edges should be consistent with those declared in the schema structure.
Method and class:
def insertEdgesBatchBySchema(self,
schema: ULTIPA_REQUEST.Schema,
rows: List[ULTIPA.Edge],
config: ULTIPA_REQUEST.InsertConfig
) -> ULTIPA_RESPONSE.InsertResponse
class Schema:
def __init__(self,
name: str,
properties: List[Property],
desc: str = None,
type: str = None,
DBType: ULTIPA.DBType = None,
total: int = None
)
class Property:
def __init__(self, name: str, type: ULTIPA.PropertyType = None, desc: str = None)
Example: Insert multiple edges into schema 'transfer' of graphset 'test', use insert mode
from ultipa import Connection, UltipaConfig, InsertConfig
from ultipa import ULTIPA_REQUEST, ULTIPA
# omit code of establishing server connection 'conn' using graphset 'default'
schema = ULTIPA_REQUEST.Schema(
"transfer",
[
ULTIPA_REQUEST.Property("amount", ULTIPA.PropertyType.PROPERTY_FLOAT),
ULTIPA_REQUEST.Property("type", ULTIPA.PropertyType.PROPERTY_STRING)
]
)
rows = [
ULTIPA.EntityRow(values = {"amount": 2000.0, "type": "I"}, from_id = "CARD000901", to_id = "CARD000A21"),
ULTIPA.EntityRow(values = {"amount": 125.5, "type": "II"}, from_id = "CARD000BB2", to_id = "CARD000C74")
]
req = conn.insertEdgesBatchBySchema(
schema,
rows,
InsertConfig(ULTIPA.InsertType.NORMAL,"test")
)
req.Print()
insertEdgesBatchAuto()
insertEdgesBatchAuto()
will insert multiple edges of multiple edge schemas. The edges should carry schema
, and the properties carried in the values
of edges should be consistent with those defined in the graphset.
Method and class:
def insertEdgesBatchAuto(self,
edges: List[ULTIPA.Edge],
config: ULTIPA_REQUEST.InsertConfig
) -> ULTIPA_RESPONSE.ResponseBatchAutoInsert
Example: Insert multiple edges into multiple schemas of graphset 'test', use overwrite mode
from ultipa import Connection, UltipaConfig, InsertConfig
from ultipa import ULTIPA_REQUEST, ULTIPA
# omit code of establishing server connection 'conn' using graphset 'default'
rows = [
ULTIPA.EntityRow(values = {"amount": 2000.0, "type": "IV"}, from_id = "CARD000901", to_id = "CARD000A21", schema = "transfer", uuid = 5),
ULTIPA.EntityRow(values = {}, from_id = "STAF000E32", to_id = "CUST000F9A", schema = "manage", uuid = 7)
]
req = conn.insertEdgesBatchAuto(
rows,
InsertConfig(ULTIPA.InsertType.OVERWRITE,"test")
)
req.Print()